This is actually very difficult unless you are using CFMX, which supplies
non-greedy matching. Assuming you are not using CFMX, we have to make a rule
that there will be no ] in your URL or URL name. 

Square brackets have meaning in regexes so we escape them with a \.
Parentheses () capture the URL and the URL name. Later we use back
references \1 and \2 to refer to them. 

[^]]* is a character class. A class is anything wrapped in square brackets.
The * means match none or more of this class, but as many as possible. ^
means match everything that is not in the following set of characters, i.e.
match everything but a closing square bracket. So the character class is
"anything but ]". 

This might have errors:

reReplaceNoCase(myString, "\[URL\]([^]]*)\[/URLNAME\]([^]]*)\[/URL\]", "<a
href=""\1"">\2</a>", "all")

Matt.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:bounce-cfaussie-
> [EMAIL PROTECTED] On Behalf Of Gareth Edwards
> Sent: Friday, 7 November 2003 12:41 a.m.
> To: CFAussie Mailing List
> Subject: [cfaussie] Regular Expressions.
> 
> Just wondering if anyone is any good with regular expressions, cos I am
> yet
> to learn them.
> 
> Can someone help me with the following using Regular Expressions. I've
> looked on CFLIB and there are some handy conversions but not quite the one
> I
> require.
> 
> [URL]Insert Address here[/URLNAME]Insert name here[/URL]
> 
> to replace it with the relivent href link.
> 
> I also need to reverse the process.. so I may return the [] names rather
> than the href link. So all the actually html stays hidden.
> 
> Cheers
> 
> Gareth.
> 
> 
> 
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to leave-cfaussie-
> [EMAIL PROTECTED]
> 
> MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
> http://www.mxdu.com/ + 24-25 February, 2004




---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to