RE: [PHP] Use of preg_replace
| From: | Dajka Tamás | Date: | Sun, 24 Jul 2011 18:35:48 +0000 |
| Subject: | RE: [PHP] Use of preg_replace | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314187@lists.php.net to get a copy of this message | ||
Hi,
I lost trail, what do you want to do?
You want to convert
>>>From
to this:
>>From
Or what's the goal?
Cheers,
Tamas
-----Original Message-----
From: Tim Streater [mailto:tim@clothears.org.uk]
Sent: Sunday, July 24, 2011 8:07 PM
To: PHP General List
Subject: [PHP] Use of preg_replace
I need to be able to convert a line of the form:
>>>From
to have either one more or one less > at the front. A web site tells me that the regexps to use
are:
1,$s/^>*From />&/
and
1,$s/^>(>*From )/\1/
respectively (there is a single space after "From"). So, if my text string is in $line, I
ought to be able to do something like:
$line = preg_replace ($pattern, $replacement, $line);
But, since all regexps are to me, like TECO commands, no better than line-noise, how do I make up
$pattern and $replacement from the proffered regexps?
Thanks.
--
Cheers -- Tim