Brian
-----Original Message-----
From: Ben Doom [mailto:[EMAIL PROTECTED]
Sent: Friday, July 23, 2004 12:27 PM
To: RegEx
Subject: Re: Parsing Variable Names... (with corrections and
explanations)
Yager, Brian CTR wrote:
> I am also trying to learn as much as I can about this stuff. If you
> have some time, can you explain what this is doing exactly?
Sure. It's actually pretty simple.
> >Sort of. You'd actually do both replaces simultaneously:
> >rereplace("##([^#])##", '"&##\1##&"', "all")
OOPs! Should be
rereplace("##([^##]+)##", '"&##\1##&"', "all")
rereplace does a regular _expression_ case-sensitive replacement. But you
knew that already.
## is the pound sign. It's doubled to escape it, just like in a cfoutput.
( ) means "remember what I've placed inside here". It's also used for
grouping and a few other things.
[ ] means "anything I've got inside here", but if the first character is
a carat ^, it means "anything *except* what I've got inside here" This
is referred to as a character class. So, [^##] means "any one character
except the pound sign".
+ means one or more. So [^##]+ basically means "anything but the pound
sign".
In the replacement field, we have a \1 which needs explanation.
Remember how I used the parens to mean "remember me"? Well, this means
"spit back the first thing you were told to remember". So if the thing
in parens matched "query.colname" then \1 puts that string back.
HTH.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
