|
Posted by Piratron on 02/17/06 20:09
Jasen Betts wrote:
> On 2006-02-16, Piratron <piratron05@gmail.com> wrote:
>> MaKroZ wrote:
>>> On Mon, 13 Feb 2006 19:09:33 +0100, Piratron wrote:
>>>
>
>> <tr><td>
>> <!--ec1-->text1<!--ec2-->
>> </td></tr>
>> <tr><td>
>> <!--ec1-->text2<!--ec2-->
>> </td></tr>
>> <tr><td>
>> <!--ec1-->text3<!--ec2-->
>> </td></tr>
>> <tr><td>
>> <!--ec1-->text4<!--ec2-->
>> </td></tr>
>> ---------------------
>>
>> the problem is that
>> ereg_replace("(<!--ec1-->).*(<!--ec2-->)","\\1$repl\\2", $string);
>> will replace text from first "<!--ec1-->" occurrence (line 2 in example)
>> and last occurrence (line 12 in example).
>
> you need a non-greedy match.
>
>
>
solved with preg_replace
preg_replace('^<!--c1-->(.*?)<!--ec2-->^s',$repl,$subject)
--
Please visit our site at:
www.symbian-mobile.org
Regards,
Symbian-Mobile Team
Navigation:
[Reply to this message]
|