Re[2]: [PHP] preg_replace();
| From: | wwww at freenet dot am | Date: | Fri, 02 Feb 2007 20:37:35 +0000 |
| Subject: | Re[2]: [PHP] preg_replace(); | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-248205@lists.php.net to get a copy of this message | ||
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: <wwww@freenet.am>
> To: "Sébastien WENSKE" <canardwc@canardwc.com>
> Cc: <php-general@lists.php.net>
> 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