Re: RE: RE: [PHP] Use of preg_replace
| From: | Tim Streater | Date: | Sun, 24 Jul 2011 20:34:00 +0000 |
| Subject: | Re: RE: RE: [PHP] Use of preg_replace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-314191@lists.php.net to get a copy of this message | ||
On 24 Jul 2011 at 19:57, Dajka Tamás <viper@vipernet.hu> wrote:
> You want to do it in a greater text, I think.
See below.
> 1,$s/^>(>*From )/\1/
>
> $line = preg_replace ($pattern, $replacement, $line);
>
> Adding one '>':
>
> preg_replace('/(^[>]+From )/','>$1', $line)
>
> Removing one '>':
>
> preg_replace('/(^>([>]+From )/','$1', $line)
^
|
Missing ) -------------------+
In fact I forgot to mention that the string always starts at the start of the line. So, I
experimented a bit and the following works:
$onemore = preg_replace ('/^(>*From )/', '>$1', $line);
$oneless = preg_replace ('/^>(>*From )/', '$1', $line);
Thanks for the help.
--
Cheers -- Tim