Try this one:
$old_string="lazy \"some chars|some chars\" dog";
$new_string=str_replace('|', '_', $old_string);
print $new_string;
Ed
Friday, February 2, 2007, 10:39:59 PM, you wrote:
> ok, but :
> $old_string="lazy \"some chars|some chars\" dog";
> $new_string=str_replace('"|"', '_', $old_string);
> don't work
> sorry for my bad english, i'm french.
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: "Sébastien WENSKE" <[EMAIL PROTECTED]>
> Sent: Friday, February 02, 2007 9:22 PM
> Subject: Re[2]: [PHP] preg_replace();
> I have tasted the code and it worked fine (if I got you right):
> $old_string="lazy \"|\" dog";
> $new_string=str_replace('"|"', '_', $old_string);
> print $new_string;
> I got "lazy_dog"
> Ed
> Friday, February 2, 2007, 10:01:14 PM, you wrote:
>> Thanks,
>> but I think that I must use preg_replace because the condition is: replace
>> the chars (pipe or space) when they are between "
>> ie : src=file:///h|/hjcjdgh dlkgj/dgjk.jpg" to
>> src=file:///h_/hjcjdgh_dlkgj/dgjk.jpg"
>> Seb
>> ----- Original Message -----
>> From: <[EMAIL PROTECTED]>
>> To: "Sébastien WENSKE" <[EMAIL PROTECTED]>
>> Cc: <[email protected]>
>> Sent: Friday, February 02, 2007 8:38 PM
>> Subject: Re: [PHP] preg_replace();
>> I am not a very experienced programmer, but I think that "str_replace"
>> can be used in this case:
>> $new_string=str_replace('|', '_', $old_string)
>> then use the same function to replace spaces.
>> Ed
>> Friday, February 2, 2007, 9:30:37 PM, you 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