Re: eregi
| From: | CC Zona | Date: | Thu, 02 May 2002 22:13:36 +0000 |
| Subject: | Re: eregi | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95781@lists.php.net to get a copy of this message | ||
In article <Pine.LNX.4.44.0205021700150.17412-100000@stoic.net>,
mnc@stoic.net (Miguel Cruz) wrote:
> On Thu, 2 May 2002, Fredrik Arild Takle wrote:
> > eregi("$start(.*)end", $rf, $my_var);
> >
> > And I want it to stop at the first presedence of $end, not the last (thats
> > what this is doing).
>
> Try preg, which is faster and gives you more control (here the ?
> munificence operator).
>
> preg_match("/{$start}(.*?)end/", $rf, my_var);
Leave out the braces.
preg_match("/$start(.*?)end/", $rf, my_var);
-or-
preg_match("/$start(.*)end/U", $rf, my_var);
(And make sure the value of $start either doesn't have any regex special
chars, or is using them intentionally, or has them escaped
<http://php.net/preg-quote>.)
--
CC