Cool! On 12/14/06, Joel Cass <[EMAIL PROTECTED]> wrote: > > > OK.. Please no messages saying "ooh.. evaluate() bad..", but > > <cfscript> > > str_text = "This works in 90% of all operations"; > > str_text = replace(str_text, "##", "####", "all"); > str_text = ReReplace(str_text, "([0-9]*)%","##\1-25##%","all"); > > result = evaluate(DE(str_text)); > > </cfscript> > > <cfdump var="#result#"> > > -----Original Message----- > From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] > Behalf Of Matthew > Sent: Thursday, 14 December 2006 12:43 PM > To: cfaussie > Subject: [cfaussie] Regular expressions - backreference as a number > > > > Hi guys, > > I need to write a regex which can search through a paragraph of text > and replace any number written as a percentage with itself minus 25% > i.e. replace 100% with 75%, 90% with 65% etc etc. > Here is a sample paragraph: > ----------------------------- > Provides passengers with a cabin that contains a 3-berth sleeping > compartment in 2nd class. 100% exchangeable and refundable up to 3 days > before departure. 90% exchangeable and refundable from 3 days before > departure up to 60 days after departure. Can be exchanged in France > prior to the travel date. > ----------------------------- > I've writen a regex to find all strings where a number has a "%" symbol > after it and replace it with "FOO": > ----------------------------- > <cfdump var="#ReReplace(str_text,"([0-9]+%)+","FOO","all")#"> > ----------------------------- > Now I want to use the backreference and subtract 25, but it seems the > backreference can only be treated as a string: > <cfdump var="#ReReplace(str_text,"([0-9]+%)+","\1-25","all")#"> > Which produces: "100%-25", wrong I know!!! > > I'm guessing that I will have to be to write a REFind and do some > replaces etc, however it would be great if someone could write it all > in a regex. > > Cheers > Matthew > > > > > > > >
--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---