Re: RE: RE: Use of preg_replace

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

 



On 24 Jul 2011 at 19:57, Dajka Tamás <viper@xxxxxxxxxxx> 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

-- 
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