Is there a better way to escape this string?
algorithm, coldfusion, java
Solution
I haven't tested this, so the syntax might be off, but you should be able to do something like:
<cfset V1 = REReplace(V1,"([0-9]{2})","\\\1","all")>
Problem
What is the quickest way in ColdFusion (or Java) for converting a string as such: ``` Input: 79827349837493827498 Output: \79\82\73\49\83\74\93\82\74\98 ``` I'm taking an LDAP GUID and escaping it for a query. I can do it as a series of MID reductions like this: ``` <CFSET V1 = ""> <CFSET RetVal = ""> <CFLOOP CONDITION="#V1# NEQ''"> <CFSET RetVal = RetVal & "\" & MID(V1,1,2)> <CFSET V1 = MID(V1,3,2000)> </CFLOOP> ``` But it seems like there would be something more elegant, like a regular expression replace.