Posted by Michael Fesser on 12/12/06 18:34
..oO(Moot)
>laredotornado@zipmail.com wrote:
>>
>> I'm having trouble with preg_match. I want to get the value in
>> parenthese from this pattern
>>
>> $pattern = "/ab(.*)cde/";
>> $str = "abxyzcde";
>>
>> What preg_match expression would i have to write to get the value "xyz"
>> into a string?
>>
>> I'm using php 4.4.4. Thanks, - Dave
>
>$pattern = "/(?<=ab)(.*)(?=cde)/";
>$str = "abxyzcde";
>preg_match($pattern,$str,$match);
>var_dump($match);
No need for assertions here. Just use the simple pattern from above and
you can find the result in $match[1].
Micha
[Back to original message]
|