-
1. Re: HtmlEditFormat() within reReplace()?
Adam Cameron. Jan 10, 2011 1:06 AM (in response to Owain North)<cfoutput>#reReplaceNoCase('<a href="hello">Something</a>', '(.*)', htmlEditFormat("\1"), 'all')#</cfoutput>
Not a massive surprise if I'm honest, as I suspect the regex pattern and string are just passed off to a java library somewhere which clearly won't understand CF, but I'm surprised it doesn't error.
Why would it error? CF will simply be htmlEditFormat()-ing "\1" before passing it to the regex processor. As neithe backslash nor 1 need escaping, this has no effect, but equally, all you end up doing is replacing everything ( (.*) ) with itself ( \1 ), hence not seeing any change.
I guess you're wanting CF to pass:
htmlEditFormat("\1")
as the substitution string (or like as some sort of callback), but that's not what happens. The CF gets run first, then the result gets passed to the regexc processor.
What you need to do is to check to see if there's anything that needs to be "escaped", then if so: extract it, escape it, then put it back in.
There's no way of doing it in a single hit.
--
Adam
-
2. Re: HtmlEditFormat() within reReplace()?
Owain North Jan 12, 2011 3:00 PM (in response to Adam Cameron.)CF will simply be htmlEditFormat()-ing "\1" before passing it to the regex processor.
Spot on actually, not really sure what I was thinking. I guess I was thinking it'd to the same replacement on CF functions as it does with the back references.
Annoying but understandable I guess, cheers Adam for taking the time.
O.

