Re: Regexp handling
| From: | Michael Dearman | Date: | Wed, 13 Dec 2000 19:50:39 +0000 |
| Subject: | Re: Regexp handling | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30128@lists.php.net to get a copy of this message | ||
Mark Rogers wrote:
>
> Does PHP support regexp back references?
>
> Eg, to pick up a quoted string:
> ereg('([\'"])([a-z]*)\1', $somestring, $somearray);
>
> If it does support this then I can't see how! I've tried all sorts of
> combinations (various ways of escaping the quotes or \ char, etc) with no
> success. I'm using PHP 4.
>
> Mark.
>
Got it to work with a preg
$pat = "/([\'\"])(.+)\\1/";
^^
preg_match($pat, $string, $arr);
But not with the ereg. And preg's seem to be faster anyway.
Mike D.