Line Nibbler Alert!!!!
My message was stripped of leading periods.
Any dot/period character in the following email was stripped if it was the first
character on a line.
Is this intentional?
<- here's one.
. .. <- here are two pairs in a row.
Jerry Johnson
>>> [EMAIL PROTECTED] 09/26/02 10:36AM >>>
I'll take a crack at it - then Ben (and everyone else) can correct me.
The players:
in this place and time, it means any single character
* means zero or more
pcode= means the literal string pcode= (but since we used rereplacenocase, it could
be PCODE= or pCoDe= etc)
() in this place and time, it means to capture what's inside it in what
is called a backreference
[] in this place and time, it means to encapsulate a character class (a
group of single characters added together and tested together)
^ in this place and time, it means NOT, as in NOT the & symbol
& means the "&" character
+ means one or more
\1 means whatever was inside the first backreference - the stuff inside the
first ()
To read the whole string:
Zero or more characters followed by the string "pcode=" followed by one or more
characters that are not the & symbol followed by zero or more characters.
In an expanded version of your example:
index.htm?someVariabl=hiThere&someothervariable=45&pCode=00343223234322&yetanothervar=who
* index.htm?someVariabl=hiThere&someothervariable=45&
pCode= pcode=
([^&]+) 00343223234322
* &yetanothervar=who
Replace all of the above with the first backreference (which in this case will be
00343223234322)
Did this help, or make it more confusing?
Jerry Johnson
>>> [EMAIL PROTECTED] 09/26/02 10:06AM >>>
Ben,
I've seen answers like this to other questions as well. I have never quite
understood what is taking place. Do you mind spending a couple of minutes to
explain what ".*pcode=([^&]+).*", "\1" does?
Thanks,
Brian Yager
President - North AL Cold Fusion Users Group
http://www.nacfug.com
Sr. Systems Analyst
Sverdrup/CIC
[EMAIL PROTECTED]
(256) 842-8342
-----Original Message-----
From: Ben Doom [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 25, 2002 4:54 PM
To: CF-Talk
Subject: RE: please do my work for me
I'm assuming this is a link somewhere in some content you're cfhttp-ing, or
you'd just use url.pCode.
Anyhow,
pcode = rereplacenocase(url, ".*pcode=([^&]+).*", "\1")
Happy regexing.
--Ben Doom
Programmer & General Lackey
Moonbow Software
: -----Original Message-----
: From: Cantrell, Adam [mailto:[EMAIL PROTECTED]]
: Sent: Wednesday, September 25, 2002 5:38 PM
: To: CF-Talk
: Subject: please do my work for me
:
:
: I want to extract a value from a URL variable which can show up
: anywhere in
: the URL. Here are some examples, I would want the pCode value which will
: always be an integer of varying length:
:
: index.htm?var1=23&pCode=100&othervar=hello -------- return 100
:
: index.htm?pCode=1 ------- return 1
:
: index.htm?someVariabl=hiThere&someothervariable=45&pCode=00343223234322
: --------- return 00343223234322
:
: If somebody can tell me the right regular expression (or if a regular
: expression isn't even needed, but just some combination of CF functions)
: that would be GREAT!
:
: Adam.
:
:
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists