|
Posted by Moot on 12/12/06 18:12
laredotornado@zipmail.com wrote:
> Hi,
>
> 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);
For documentation, look under the "Assertions" heading here:
http://us3.php.net/manual/en/reference.pcre.pattern.syntax.php
- Moot
Navigation:
[Reply to this message]
|