View Single Post
Old 03-03-2015, 05:06 PM   #1
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
RegEx to replace only inside certain tags?

If there is something like

<h1>Text Text <b>Bold Text</b> Text Text</h1>

<p>Text Text <b>Bold Text</b> Text Text</p>

Q: is there a way to replace (delete) the <b> and </b> only if they are inside the h1 tags?

I got this far

Find: (<[Hh][1-6]>)(.+?)(<[biu]>)(.+?)(</\3>)(.+?)<(</[Hh][1-6]>)

Replace: \1\2\4\6\7

but it doesn't work because I can't figure out how to get the red back reference to match the blue tag

Q2: is there a better way?
phossler is offline   Reply With Quote