I don't know of any regex engine that will perform numeric operations. Possibly perl. The CF regex engine is VERY cutdown. The best workaround I can think of is to use refind with subexpressions and then loop through the result array.
Blair On 12/14/06, Matthew <[EMAIL PROTECTED]> wrote: > > > 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 -~----------~----~----~----~------~----~------~--~---