RE: Ben Doom (was please do my work for me)

2002-09-26 Thread Yager, Brian T Contractor/Sverdrup

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=23pCode=100othervar=hello  return 100
:
: index.htm?pCode=1 --- return 1
:
: index.htm?someVariabl=hiTheresomeothervariable=45pCode=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.
:
: 

__
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Ben Doom (was please do my work for me)

2002-09-26 Thread Ben Doom

: 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?

Well, the 'pcode=' bit ought to be obvious.  All it does is find that
literal substring in the string we're searching.  '[^]' matches any single
character except the ampersand -- the [] brackets delimit a character class
and the ^carat means to negate the character class.  So [abc] would match a,
b, or c but not d or 7 and [^abc] would match d and 7 but not a b or c.
'[^]+' means at least one not-, and as many as you can find in a row.
Putting parans around it means remember me.  The '.' (period or dot) is a
wildcard -- it matches /anything/ and the '*' asterisk means as many as you
can match.  So the '.*' at the beginning and end of the regex serve to grab
everything before and after the part we want to recognize.  We replace it
with '\1' which means the first backreference which is the first bit in
parens (well, the only bit in parens) so we're replacing the entire string
with everything between 'pcode=' and either the very next '' it comes
across or the end of the string, whichever is first.

I subscribe to the CF-Regex list, and you should, too.  :-)  You can
subscribe here:
http://www.houseoffusion.com/cf_lists/index.cfm?forumid=21

We've got an interesting session going over there about stripping or keeping
tags based on a list, and S. Isaac Dealey has written a UDF based on
suggestions from the group.  If you're interested in learning how to use
Regex to do some of your heavy lifting, come join us.



  --Ben Doom
Programmer  General Lackey
Moonbow Software

__
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Ben Doom (was please do my work for me)

2002-09-26 Thread Mike Wokasch

Brian -
It's a regular expression.

It says, find a part of the string that starts with 'pcode=' and is 
followed by 0 or many characters that are you  which could be followed by 
anthing else.

How's that?

Mike Wokasch
UW-Extension
At 09:06 AM 9/26/2002 -0500, you wrote:
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=23pCode=100othervar=hello  return 100
:
: index.htm?pCode=1 --- return 1
:
: index.htm?someVariabl=hiTheresomeothervariable=45pCode=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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Ben Doom (was please do my work for me)

2002-09-26 Thread S . Isaac Dealey

This is a Regular Expression (regex) -- a system of finding and replacing
complex strings which originated ( i believe ) with PERL. There's a section
of the ColdFusion user's manual titled Using Regular Expressions or
something to that effect which gives an explanation of regex and how it
works in ColdFusion ( which at least in CF 5 and prior was a little
different than in PERL ) ...

But to give you a brief example, this expression that ben provided:

REReplace(mystring,.*pcode=([^]+).*, \1)

The . in the regular expression matches any character, and the * is a
modifier which tells the engine to find 0 or more occurrances of the
previous character ( or set of characters in [] or subexpression ). The
parenthesis are a subexpression, which are used primarily for
back-references -- the \1 in the replace statement is a back-expression
which means, insert the first subexpression in the replacement string. The
[] inside the subexpression denote a set of characters and the ^ inside the
set ( which at the beginning of the regex would mean beginning of string ),
means not in , so [^] matches all characters which are not  . The + like
the * matches 1 or more instances of the previous character, set or
subexpression. So what you get after all of this is the string 'pcode=',
then find any character other than '' after the string 'pcode=' and return
that string or subexpression.


S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046
__
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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Ben Doom (was please do my work for me)

2002-09-26 Thread Jerry Johnson

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

\1means 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=hiTheresomeothervariable=45pCode=00343223234322yetanothervar=who


*index.htm?someVariabl=hiTheresomeothervariable=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=23pCode=100othervar=hello  return 100
:
: index.htm?pCode=1 --- return 1
:
: index.htm?someVariabl=hiTheresomeothervariable=45pCode=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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Ben Doom (was please do my work for me)

2002-09-26 Thread Yager, Brian T Contractor/Sverdrup

Thanks Ben...I think I will join.

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: Thursday, September 26, 2002 9:21 AM
To: CF-Talk
Subject: RE: Ben Doom (was please do my work for me)


: 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?

Well, the 'pcode=' bit ought to be obvious.  All it does is find that
literal substring in the string we're searching.  '[^]' matches any single
character except the ampersand -- the [] brackets delimit a character class
and the ^carat means to negate the character class.  So [abc] would match a,
b, or c but not d or 7 and [^abc] would match d and 7 but not a b or c.
'[^]+' means at least one not-, and as many as you can find in a row.
Putting parans around it means remember me.  The '.' (period or dot) is a
wildcard -- it matches /anything/ and the '*' asterisk means as many as you
can match.  So the '.*' at the beginning and end of the regex serve to grab
everything before and after the part we want to recognize.  We replace it
with '\1' which means the first backreference which is the first bit in
parens (well, the only bit in parens) so we're replacing the entire string
with everything between 'pcode=' and either the very next '' it comes
across or the end of the string, whichever is first.

I subscribe to the CF-Regex list, and you should, too.  :-)  You can
subscribe here:
http://www.houseoffusion.com/cf_lists/index.cfm?forumid=21

We've got an interesting session going over there about stripping or keeping
tags based on a list, and S. Isaac Dealey has written a UDF based on
suggestions from the group.  If you're interested in learning how to use
Regex to do some of your heavy lifting, come join us.



  --Ben Doom
Programmer  General Lackey
Moonbow Software


__
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Ben Doom (was please do my work for me)

2002-09-26 Thread S . Isaac Dealey

 I subscribe to the CF-Regex list, and you should, too.  :-)  You can
 subscribe here:
 http://www.houseoffusion.com/cf_lists/index.cfm?forumid=21

 We've got an interesting session going over there about stripping or
 keeping
 tags based on a list, and S. Isaac Dealey has written a UDF based on
 suggestions from the group.  If you're interested in learning how to use
 Regex to do some of your heavy lifting, come join us.


Now why didn't I remember to plug the group? :)

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046
__
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists