try #reReplace(html, '(<a[^>]*>)(.?)(</a>)', '\2', 'all')# perhaps you want to remove title="foo" etc as well?
Dale Fraser wrote: > I don’t understand this > > <cfsavecontent variable="html"> > aaa<a name="12345" id="12345"></a>xxx > bbb<a name="12345" id="12345"></a>yyy > ccc<a name="12345" id="12345"></a>zzz > </cfsavecontent> > <cfoutput> > #reReplace(html, '<a name=".*" id=".*">.*</a>', '', 'all')# > </cfoutput> > <cfabort /> > > What I get is aaazzz > > So its matching from the first <a to the last </a> > > Any ideas, I'll keep trying. > > Regards > Dale Fraser > > > -----Original Message----- > From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf > Of Adam Cameron > Sent: Tuesday, 25 November 2008 8:24 PM > To: cfaussie > Subject: [cfaussie] Re: RegEx Banging Head > > > On Nov 24, 11:58 pm, "Steve Onnis" <[EMAIL PROTECTED]> wrote: >> REReplaceNoCase(string, "<a([^(href)]*) > (href="")([^""]*)("")>([^<]*)</a>", >> "\3", "ALL"); > > Hi Steve. > I'm not sure this bit is right: > > [^(href)] > > That matches any single character that is not "(", "h", "r", "e", "f" > or ")". square brackets mean "match a single character". One cannot > stick parentheses in there to match a sequence (or in your attempt, > *not* match a sequence). > > I think Robin's example is fine, but I'd perhaps augment it to make > sure the href is within an anchor tag (as opposed to in a link tag, > for example): > > <a\s[^>]*?href\s*?=\s*?([""'])([^\1]*?)\1[^>]*?> > > Of course it depends on the source string as to whether this is > necessary. If it's already just going to be solely the anchor tag and > its contents, there's no need for this. However if one is parsing a > longer string holding an HTML document, this might be a safer way of > doing it. > > To Dale: CF's regexes aren't that much different from JavaScript and > Perl ones, and the main differences are less-commonly-used features in > my experience (coming from CF, they're "less-commonly-used" because CF > doesn't support 'em ;-). It's rare that when I need to look one up > that it won't work on CF. Obviously your experience varies here, > which surprises me. > > I would make a point of using regexes as much as possible. Whenever > one finds oneself thinking that perhaps to process a string one might > need to loop over it; a regex find / replace is almost always going to > be another possible option to consider. And they do seem a bit > impenetrable at first, but with only a superficial amount of > practise / repetition, the muddy waters start to clear. > > I find this site a useful resource for explanations how various regex > expressions work: http://www.regular-expressions.info/tutorial.html > > Oh, and Robin: cheers for the heads-up re that Eclipse plug-in. I > also use regex coach: http://www.weitz.de/regex-coach/ > > -- > Adam > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---