ColdFusion - pass regex backreference to function call

Posted by stubotnik on Stack Overflow See other posts from Stack Overflow or by stubotnik
Published on 2010-05-06T10:46:54Z Indexed on 2010/05/06 12:18 UTC
Read the original article Hit count: 216

Filed under:
|
|
|

Hi,

I'm using ColdFusion's reReplace() function for regular expression pattern replacement.

I'd like to use a function call for the replacement string, and pass a matched backreference to it.

Something like this:

<cfset s = "STARTDATE_2010-05-07 00:05:00.0_ENDDATE" />
<cfset s = reReplace(s, "STARTDATE_([\s-.:0-9]*)_ENDDATE", dateAdd("h", 1, "\1")) />

But that fails because "The value of parameter 3, which is currently \1, must be a class java.util.Date value."

Is there any other way to achieve this?

Thanks, Stu

© Stack Overflow or respective owner

Related posts about coldfusion

Related posts about regex