I\'m guessing it\'s not a Perl Compatible Regular Expression, since there\'s a special kind of grep
which is specifically PCRE. What\'s grep
most simil
There is no regular grep function in PHP. If you are referring to the ereg family of PHP functions then those are POSIX regular expressions. If you are referring to the Linux grep
commandline utility, those are POSIX regular expressions as well. It supports both basic as well as extended POSIX regular expressions.
You can compare the various flavors here.
The grep man pages do a pretty thorough job of explaining the flavor of regexp available in grep. man grep
is pretty useful.
Default GNU grep
behavior is to use a slightly flavorful variant on POSIX basic regular expressions, with a similarly tweaked species of POSIX extended regular expressions for egrep
(usually an alias for grep -E
). POSIX ERE is what PHP ereg() uses.
GNU grep
also claims to support grep -P
for PCRE, by the way. So no terribly special kind of grep
required.
Grep is an implementation of POSIX regular expressions. There are two types of posix regular expressions -- basic regular expressions and extended regular expressions. In grep, generally you use the -E option to allow extended regular expressions.
There's a good write-up here. To quote the page, "grep is supposed to use BREs, except that grep -E uses EREs. (GNU grep fits some extensions in where POSIX leaves the behaviour unspecified)."
In other words, it's a long story. ;)