Re: which regexp require preg_grep() and which can be used with ereg()?
| From: | CC Zona | Date: | Sat, 06 Oct 2001 18:03:30 +0000 |
| Subject: | Re: which regexp require preg_grep() and which can be used with ereg()? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70229@lists.php.net to get a copy of this message | ||
In article <20011005222902.49675.qmail@pb1.pair.com>,
jazrant@zsc.nrcan.zc.ca (John A. Grant) wrote:
> In Perl I used "/\S/" to check for blank lines read from a file.
> Now I'm learning PHP. How do I know what is a 'standard'
> regexp that ereg() can handle and how do I know what is
> Perl-specific syntax so that I must use preg_grep() instead?
The preg_* functions are faster and more powerful than ereg_*. So the main
reason to ever use an ereg is because one both unfamiliar with PCRE syntax
and uninterested in learning it. You already know Perl regex, so no
problem there: you do know PCRE (or will, with a five minute study of the
manual to learn the minor differences between Perl and PCRE syntax).
If you feel like learning ereg syntax too, google for "POSIX regular
expressions", to numerous copies of the relevant man page (regex (6),
IIRC..?). You'll find it easy to learn!
--
CC