buzibuzi
buzibuzi

Reputation: 734

regex to replace HTML sorrounding tag

im trying to replace an html tag with another one using notepad++ search and replace. i would like this:

<strong style="font-size: 1em;"><br />some text</strong>

to become this

<h3>some text</h3>

so far i have reached this:

<strong style="font-size: 1em;"\s(.*?)><br />(.*?)</strong>

and am not sure what to put inside "replace with", is this ok:

 <h3>$1</h3>

?

Thanks

Upvotes: 0

Views: 53

Answers (2)

Srinath Mandava
Srinath Mandava

Reputation: 3462

The regex should be this for catching...

<strong style="font-size: 1em;"\s?(.*?)><br />(.*?)</strong>

this \s should be optional according to your html

Upvotes: 1

M.P. Korstanje
M.P. Korstanje

Reputation: 12059

Try this as the replacement pattern.

<h3>\2</h3>

You can reference capture groups (between parenthesis) in the regex by \n where n is the number of the group.

Upvotes: 2

Related Questions