Don't think a single regEx will do it for ya. You could use the following code though
(mind the wrapping):
<!--- While we still have the string to remove in our text --->
<cfloop
condition="#REFindNoCase('<a[^>]+href=\"javascript:popUpJargonDefinition\([0-9]+\)\">',text)#">
<!--- Remove an occurance --->
<cfset
text=REReplaceNoCase(text,"(.*)<a[^>]+href=""javascript:popUpJargonDefinition\([0-9]+\)"">([^<]+)</a>(.*)","\1\2\3")>
</cfloop>
HTH
-Ryan
-----Original Message-----
From: Pascal Peters [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 10:33 AM
To: CF-Talk
Subject: RE: RegEx Help! (more detail)
As I wrote in my previous mail, this will not work if you have more than
one link in the text. Adding "ALL" when using a regexp that matches
start and end (^...$) is pointless, as you can have only one occurrence.
Also, this will replace the entire text by just the label between the
anchor tag. The remark about the parens is correct, but I already
corrected that.
-----Original Message-----
From: Ben Doom [mailto:[EMAIL PROTECTED]
Sent: donderdag 20 maart 2003 16:02
To: CF-Talk
Subject: RE: RegEx Help! (more detail)
<cf_homer>Doh!</cf_homer>
I think I see the problem -- the parens. We must escape the set that's
actually in the text!
<CFSET bodyText = REReplaceNoCase (publishGetArticleOnContentId.body1,
'^.*<A class=jargon
href="javascript:popUpJargonDefinition\([0-9]*\)">([^<]*)</a>.*$',"\1",
'all')>
I also added 'all' to the rereplacenocase() so that it will strip all
instances of this, rather than just the first one. Try that. I think it
will work better.
-- Ben Doom
Programmer & General Lackey
Moonbow Software, Inc
: -----Original Message-----
: From: Oliver Cookson [mailto:[EMAIL PROTECTED]
: Sent: Thursday, March 20, 2003 4:43 AM
: To: CF-Talk
: Subject: RE: RegEx Help! (more detail)
:
:
: Hi Jochem,
:
:
:
: Thanks for the reply (and the others who replied too!).
:
:
:
: Ok let me explain myself a little better. I am outputting a page of
: text
:
: and if the user chooses to turn off the "jargon" links i want to
: strip
:
: all links that look like this out:
:
:
:
: <A class=jargon
: href="javascript:popUpJargonDefinition(2)">article</A>
:
:
:
: You say that would be easy?
:
:
:
: Well i want to keep the text inbetween the <A></A> tags (in this
:
: case "article") and the argument i am passing to the JS function
: could
:
: be ANY number (from 1 to 2000? As this is the ID of the jargon.)
:
:
:
: I need to replace ALL occurences of this text within the large
: string.
:
:
:
: I tried this RegEx below but it didn't work? (sorry for the
: text-wrap)
:
:
:
: <CFSET bodyText = REReplaceNoCase
:
: (publishGetArticleOnContentId.body1,'^.*<A class=jargon
:
: href="javascript:popUpJargonDefinition([0-9]*)">([^<]*)</a>.*$',"\1")>
:
:
:
: Thanks in advance and any help would be appreciated. :)
:
:
:
: Oliver
:
:
:
:
:
: > : -----Original Message-----
:
: > : From: Jochem van Dieten [mailto:[EMAIL PROTECTED]
:
: > : Sent: Friday, March 14, 2003 6:23 AM
:
: > : To: CF-Talk
:
: > : Subject: Re: SOT: RegEx Help!
:
: > : Do you mean this string is part of a larger text? Use:
:
: > : <cfset text = REReplaceNoCase(text,'^.*<A class=jargon
:
: > :
: href="javascript:popUpJargonDefinition([0-9]*)">(.*)</a>.*$',"\1")>
:
: > : else:
:
: > : <cfset text = REReplaceNoCase(text,'<A class=jargon
:
: > : href="javascript:popUpJargonDefinition([0-9]*)">(.*)</a>',"\1")>
:
: > :
:
: > : Jochem
:
:
:
:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4