Re: which regexp require preg_grep() and which can be used with ereg()?

From: Date: Mon, 08 Oct 2001 04:00:26 +0000
Subject: Re: which regexp require preg_grep() and which can be used with ereg()?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-70315@lists.php.net to get a copy of this message
In article <20011008024151.15354.qmail@pb1.pair.com>, jazrant@zsc.nrcan.zc.ca (John A. Grant) wrote: > What is the simplest way to check for a blank line (just > spaces, tabs etc.) read from a file using ereg()? I couldn't > find any equivalent for the Perl "/\S/". I still don't understand why you would bother looking for an ereg equivalent when you can just use "/\S/" as-is with a preg_*, but <shrug>... \S means "not a whitespace character" in Perl/PCRE. There's not a special character in POSIX for that, but you can use a negative character class instead: "[^[:space:]]" or "[^\t\r\n ]" > I must admit that > contrary to your conclusion that I already know Perl regex, > I'm a bit of a newbie at regex and the little I know came > from the (excellent) Perl doc examples. Okay, since you find that easy to read, then by all means keep on familiarizing yourself with it. Like I said before, once you know Perl regex syntax it takes maybe 5 minutes to pickup the minor differences needed for PCRE. If you're looking for a book teaching Perl and POSIX syntax in-depth, "Mastering Regular Expressions" (O'Reilly) by Jeffrey Friedl is the one to get. There are also many, many basic tutorials on the web that address POSIX regular expressions syntax (commonly referring to it simply as "extended regular expressions") if you're still finding the POSIX docs "incomprehensible". Cheers! -- CC

« previous php.general (#70315) next »