Re: preg_replace();

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux