Hi,
I suck at regex and need a bit of help. I need to take the query string from a page and do a search and replace on the page variable so I can re-write it.
Assume this:
query string = ?search=whatever&page=5
I need the rule to be like this:
Find page= which is then followed by any number of [0-9] keeping in mind that it might be blank or followed by another get variable after it (in which case stop before the & sign).
I have this (basic as if the page variable is at the end of the query string):
$new_q = preg_replace ("page=[0-9]+", "page=" . $new_page, $_SERVER["QUERY_STRING"]);
It doesn't work though. What am I doing wrong? Any thoughts?
Thanks alot.
NATE
Got a question? Search G O O G L E first.
I suck at regex and need a bit of help. I need to take the query string from a page and do a search and replace on the page variable so I can re-write it.
Assume this:
query string = ?search=whatever&page=5
I need the rule to be like this:
Find page= which is then followed by any number of [0-9] keeping in mind that it might be blank or followed by another get variable after it (in which case stop before the & sign).
I have this (basic as if the page variable is at the end of the query string):
$new_q = preg_replace ("page=[0-9]+", "page=" . $new_page, $_SERVER["QUERY_STRING"]);
It doesn't work though. What am I doing wrong? Any thoughts?
Thanks alot.
NATE

Got a question? Search G O O G L E first.