I'm trying to ReReplace the actual beginning/ending tags within a string.
For example, I want to replace
<p class="style4">My Title Is This<p>
with
<h2>My Title Is This</h2>
I wrote the code below, which seems to find the tags properly within my string, but it's replacing it with <h2>(.+?)</h2>
<cfset this.text2 = ReReplaceNoCase(getThis.statictext, '<p[^>]+class="style4"[^>]*>(.+?)</p>', '<h2>(.+?)</h2>', "ALL")>
Can anyone tell me what I'm missing here?
Thanks
In place of this:
'<h2>(.+?)</h2>'you’ll want to use the backreference\1to refer to the subexpression(.+?):Hope this helps.
UPDATE: Edited per Mike Causer’s suggestion below.