|
Posted by somebody on 09/08/05 13:27
Thanks, it is working
Rob
"Oli Filth" <catch@olifilth.co.uk> schreef in bericht
news:1126172293.740026.177040@g14g2000cwa.googlegroups.com...
> You need to check
> http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php.
>
> Firstly, you need to check the greediness of your "*"s, i.e. either by
> using PCRE_UNGREEDY, or by using "*?" rather than "*".
>
> You may also need to add the PCRE_DOTALL modifier, so that "." extends
> over newline characters.
>
> --
> Oli
>
>
> somebody wrote:
>> Hello all,
>>
>> I have the following code:
>>
>> <?php
>>
>> $s =<<< eof
>>
>> some text {FIRST} middle text {SECOND}other text
>>
>> some text {THIRD} middle text other text
>>
>> eof;
>>
>> preg_match_all('/.*{(.*)}.*/',$s,$matches);
>> print_r($matches);
>>
>> ?>
>> Results:
>>
>> Array
>> (
>> [0] => Array
>> (
>> [0] => some text {FIRST} middle text {SECOND}other text
>> [1] => some text {THIRD} middle text other text
>> )
>>
>> [1] => Array
>> (
>> [0] => SECOND
>> [1] => THIRD
>> )
>>
>> )
>> the results will only matches the last {xxx} on a line ( in this case
>> {SECOND}. I also need to get FIRST. How do I change my pattern to
>> accomplish
>> this?
>>
>> Thanks in advance
>> Rob
>
[Back to original message]
|