[thelist] RegEx Fun

.jeff jeff at members.evolt.org
Fri Jan 4 16:58:40 CST 2002


anthony,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Anthony Baratta
>
> > i need some assistance from those of you with more
> > confidence with regular expressions than i have.  i'm
> > looking to create a couple that will strip substrings
> > from a longer string.  i have 3 patterns i'd like to
> > match and remove, if found.  the one caveat is that
> > i'm using coldfusion and am therefore limited to it's
> > regex rules.
>
> Wouldn't it be easier to use the built in Query String
> parsing? With ASP, Perl, PHP there are built in or
> customizable functions that will parse the Query String
> into it's respective key=>value pairs. I don't know what
> ColdFusion has.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

i'm not looking to analyze the actual query string.  rather, i'm passing a
string via a form element.  this string happens to be a url, complete with
query string.  this string, if present, is then used by the processing page
to know what url to return the user to once the processing is complete.
however, there are some elements i need to be able to strip from this string
so they don't get doubled-up, like the "pageresponse" name/value piece i was
referring to.

to see what i'm talking about, check out the project i'm working on right
now:

http://documents.pape.com/

to see the problem occur, follow these steps:

 1) add any item to your basket
 2) take notice of the url once it's added

http://documents.pape.com/index.cfm?pageresponse=Item%20added&cfid=2127482&c
ftoken=32024994
 3) add another item to your basket
 4) take notice of the url again:

http://documents.pape.com/index.cfm?pageresponse=Item%20added&cfid=2127482&c
ftoken=32024994&pageresponse=Item%20added&cfid=2127482&cftoken=32024994
 5) click the search button (top right)
 6) do a search for "s" (without the quotes)
 7) take notice of the url again:

http://documents.pape.com/search/?keywords=s&option=any&maxrows=10&cfid=2127
482&cftoken=32024994
 8) add another item to your basket
 9) take notice of the url again:

http://documents.pape.com/search/?keywords=s&option=any&maxrows=10&cfid=2127
482&cftoken=32024994&pageresponse=Item%20added&cfid=2127482&cftoken=32024994
10) add another item to your basket
11) take notice of the url once again:

http://documents.pape.com/search/?keywords=s&option=any&maxrows=10&cfid=2127
482&cftoken=32024994&pageresponse=Item%20added&cfid=2127482&cftoken=32024994
&pageresponse=Item%20added&cfid=2127482&cftoken=32024994

do you see what i'm trying to avoid now?

there are other ways of achieving a fix to this problem[1] that don't
involve regular expressions.  however, i know they'll work in this instance
and was hoping to use this as an opportunity to learn something new.


[1]
instead of creating the return url string from cgi.script_name and
cgi.query_string, i could construct it manually using only those url
variables i know the page needs to have to display the data correctly and
leaving out those url variables that are going to cause problems on the
process page.

thanks,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/






More information about the thelist mailing list