Ok. I know there were no comments. I removed them to make you think (yes,
that's why...).

what happens is that ColdFusion evaluates the string. Say that the string
is:

        "Our product is #1 in 25% of the selected demographic"

..if the line were not there, after processing it would be evaluated as

        "Our product is #1 in #25-25#% of the selected demographic"

..which would cause a coldfusion parsing error

so, what this line does is effectively escape the existing hashes, so the
string becomes:

        "Our product is ##1 in #25-25#% of the selected demographic"

..which evaluates as

        "Our product is #1 in 0% of the selected demographic"

which unfortunately can be true at times...

-------------------------------------

SO, with comments

<cfscript>

.......

// escape any hashes in the existing string
str_text = replace(str_text, "##", "####", "all");

// replace any percentage values with coldfusion code to
// subtract 25% from existing values
str_text = ReReplace(str_text, "([0-9]*)%","##\1-25##%","all");

// evaluate coldfusion code
result = evaluate(DE(str_text));

</cfscript>

I hope that clears things up

Joel

(The old-hatter cookie cleaver)

-----Original Message-----
From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED]
Behalf Of Matthew
Sent: Thursday, 14 December 2006 1:55 PM
To: cfaussie
Subject: [cfaussie] Re: Regular expressions - backreference as a number



Someone is a very cleaver cookie!!!
Although what is this line for?: str_text = replace(str_text, "##",
"####", "all");





--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to