regex help please!
Posted: Mon Feb 24, 2003 10:12 am
Hi all,
I'm using the following to try and replace urls in my html output:
$newhrefs = preg_replace("/script.php\?(.*)=(.*)&(.*)=(.*)&(.*)=(.*)/", "script-$1-$2-$3-$4-$5-$6.html", $hrefs);
This works fine as long as there are exactly 3 var=val pairs... not 1 or 2 or 4 or more...
How can I write my expression to match 1 or more pairs??? For example:
script.php?var=val
script.php?var=val&var2=val2
script.php?var=val&var2=val2&var3=val3
script.php?var=val&var2=val2&var3=val3&var4=val4
etc...etc...etc...
TIA,
Shawn
I'm using the following to try and replace urls in my html output:
$newhrefs = preg_replace("/script.php\?(.*)=(.*)&(.*)=(.*)&(.*)=(.*)/", "script-$1-$2-$3-$4-$5-$6.html", $hrefs);
This works fine as long as there are exactly 3 var=val pairs... not 1 or 2 or 4 or more...
How can I write my expression to match 1 or more pairs??? For example:
script.php?var=val
script.php?var=val&var2=val2
script.php?var=val&var2=val2&var3=val3
script.php?var=val&var2=val2&var3=val3&var4=val4
etc...etc...etc...
TIA,
Shawn