Can you compound back references Ie if I find
<div>blah</div> And lets say <div> is ref1, blah is ref2 and </div> is ref 3 Can you rereplace with something like /1xyz/2 Thus replacing blah with xyz? Regards Dale Fraser -----Original Message----- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Onnis Sent: Tuesday, 25 November 2008 5:40 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: RegEx Banging Head anything that is surrounded by () is grouped and is returned as a back reference so <cfset string = '<a class="classname" onclick="bla();" href="bla.html">mylink</a>" /> <cfoutput> #REReplaceNoCase(string, "<a([^(href)]*)(href="")([^""]*)("")>([^<]*)</a>", "\3", "ALL")# </cfoutput> \1 = class="classname" onclick="bla();" \2 = href=" \3 = bla.html \4 = " \5 = mylink so because you are compounding everything together to get the whole a tag, you can replace the a tag with a back referenced value. so another example could be that you want to strip out all the attributes other than the href. you could do that with.. REReplaceNoCase(string, "<a([^(href)]*)(href="")([^""]*)("")>([^<]*)</a>", "<a href=""\3"">\5</a>", "ALL") For reference i actually use the regular expressions cf docs (http://livedocs.adobe.com/coldfusion/8/htmldocs/regexp_01.html) Steve -----Original Message----- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dale Fraser Sent: Tuesday, 25 November 2008 5:28 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: RegEx Banging Head Im trying to use it, I even have Ben Forta Regular Expressions in 10 minutes. I get the basic stuff, but the more complex stuff baffles me. That last one Steve posted was a killer. Regards Dale Fraser http://learncf.com http://flexcf.com -----Original Message----- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mark Mandel Sent: Tuesday, 25 November 2008 5:17 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: RegEx Banging Head I always find it really funny how people try and avoid regex. I * love * regex, and use it quite regularly, including doing all sorts of crazy find and replaces in Eclipse to essentially do code generation. Regex FTW ;) RLY! Mark On Tue, Nov 25, 2008 at 4:58 PM, Dale Fraser <[EMAIL PROTECTED]> wrote: > Thanks Steve, > > > > That seems to work, I was way off. > > > > The last thing I need to do is to replace something within a tag with > something else. > > > > Ie > > > > <class name="xyz">This is the good stuff</class> > > > > With > > > > <class name="xyz">Something Else</class> > > > > Regards > > Dale Fraser > > http://learncf.com > > http://flexcf.com > > > > > > From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf > Of Steve Onnis > Sent: Tuesday, 25 November 2008 10:58 AM > To: cfaussie@googlegroups.com > Subject: [cfaussie] Re: RegEx Banging Head > > > > Dale > > > > I already gave you that in my last message > > > > > > REReplaceNoCase(string, "<a([^(href)]*) (href="")([^""]*)("")>([^<]*)</a>", > "\3", "ALL"); > > > > Steve > > > > > > ________________________________ > > From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf > Of Dale Fraser > Sent: Tuesday, 25 November 2008 10:31 AM > To: cfaussie@googlegroups.com > Subject: [cfaussie] RegEx Banging Head > > Ok, > > > > I suck at Regular Expressions, I don't know why, but I just don't get them, > someone should write a nice web based builder. I also hate how CF ones are > different to the rest of the world so the examples I google often don't > work. > > > > Ive done this before but cant get it to work this time, how do I pull the > url out of a href > > > > Ie > > > > <a href="http://www.ihateregex.com">Please Click Here</a> > > > > And I want the url from the http to the .com > > > > Regards > > Dale Fraser > > http://learncf.com > > http://flexcf.com > > > > > > <BR > > > > -- E: [EMAIL PROTECTED] W: www.compoundtheory.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---