Re: preg_replace();

From: Date: Fri, 02 Feb 2007 20:01:38 +0000
Subject: Re: preg_replace();
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-248207@lists.php.net to get a copy of this message
This always works for me: if (preg_match_all("!\"(.+)\"!sU", $var, $match)) { for ($i=0; $i<count($match[0]); $i++) { $old = $match[1][$i]; $new = preg_replace("!\|| !", "_", $old); $var = str_replace("\"$old\"", "\"$new\"", $var); } } On Fri, Feb 02, 2007 at 07:30:37PM +0100, Sébastien WENSKE wrote: > Hi all, > > I want replace the "|" (pipe) and the " " (space) chars where are between > " (double-quotes) by an underscore "_" with the preg_replace(); funtction. > > Can someone help me to find the correct regex. > > Thanks in advance > > Seb

« previous php.general (#248207) next »