Re: preg_replace(); [solved]

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

 



nice !

thanks Steffen & Ed !

i've just add '[src|background] *= *' to make sure that the replacement takes effect only in THML tag's attributes

if (preg_match_all("![src|background] *= *\"(.+)\"!sU", $htmlContent, $match))
{
 for ($i=0; $i<count($match[0]); $i++)
 {
   $old = $match[1][$i];
   $new = preg_replace("!\|| !", "_", $old);
   $htmlContent = str_replace("\"$old\"", "\"$new\"", $htmlContent);
 }
}

----- Original Message ----- From: "Steffen Ebermann" <eseh@xxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Cc: "Sébastien WENSKE" <canardwc@xxxxxxxxxxxx>
Sent: Friday, February 02, 2007 9:01 PM
Subject: Re:  preg_replace();


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