Re: Regular expressions

From: Date: Thu, 27 Nov 2003 09:36:06 +0000
Subject: Re: Regular expressions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-171182@lists.php.net to get a copy of this message
On Thu, Nov 27, 2003 at 01:20:57PM +0400, Sheni R. Meledath wrote: : : Could anybody help me to create a regular expression to remove a pattern : from a string. : : $querystring = http://10.100.1.7/cdms/prfl.phtml?action=search&custtype=1&gender=&x=22&y=10&page=2 : : I would like to remove "&page=2" from this query string. The page number : changes. That is the reason why I want to use regular expression to replace : the variable & value from the string. $qstring = preg_replace('/&?page=\d*/i', '', $querystring); : Now I am using this option to remove the variable name only, so that it : will not collide with the variable value that is submitted again. Instead of using regexps on the URL, it might be easier (and safer) to loop through $_GET, build a new $geturl array, add/delete/change any variables in $geturl, then build a new $geturlstr string that can then be appended to your hyperlinks.

« previous php.general (#171182) next »