[thelist] Regular Expression Needed

Chris Blessing webguy at mail.rit.edu
Sat Dec 8 15:50:09 CST 2001


Joshua-

I know this may not seem relevant, but when I'm faced with a situation like
this I generally do this:

Write a <FORM> to the client and make whatever link would have done the
regex replacement submit the form instead (form could use post or get, but
get for querystring manipulation).  Something like:

<FORM METHOD="get" ACTION="whatever.foo" NAME="qsForm">
<INPUT TYPE="hidden" NAME="page" VALUE="2">
</FORM>

<A HREF="javascript:document.qsForm.submit();">Click here to see page 2</A>

This way you're sticking to client-side manipulation and you don't have to
worry about JS regexp compatibility.

-Chris

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Joshua Olson
Sent: Saturday, December 08, 2001 3:29 PM
To: thelist at lists.evolt.org
Subject: [thelist] Regular Expression Needed


I'm looking for a replacement regular expression that performs the following
task:

Given a valid URL, I want to:

1) update a parameter in the query string to a new value
or
2) append the new value to the query string

Some examples:

URL: www.mydomain.com/?page=1
Values: "page" and "2"
Result URL: www.mydomain.com/?page=2

URL: www.mydomain.com/?foo=bar
Values: "page" and "2"
Result URL: www.mydomain.com/?foo=bar&page=2

etc.

Can this be done with one single RegEx?

TIA,
-joshua


---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list