PHP extension text processing-the difference between PCRE and POSIX regular expressions is from PHP 5.3.0, and POSIX regular expression extensions are discarded. There are some differences between POSIX regular expressions and PCRE regular expressions. This article lists the most significant differences you need to know when switching to PCRE.
The PCRE function requires the mode to be closed with delimiters.
Unlike POSIX, PCRE extensions do not have functions specifically for case-insensitive matching. Instead, you can use the I (PCRE_CASELESS) pattern modifier to perform the same job. Other pattern modifiers can also be used to change matching policies.
The POSIX function looks for the longest match from the left, but the PCRE stops after the first legal match. If the string does not match, there is no difference, but if the string does not match, both results and speeds are different. To illustrate this difference, consider the following example (from Jeffrey Friedl's book Mastering Regular expressions ). Usage mode one (self )? (Selfsufficient )? Match on the string oneselfsufficient. PCRE will match oneself, but with POSIX, the result will be the entire string oneselfsufficient. Both substrings match the original string, but POSIX returns the longest result.
Function comparison table
POSIX
PCRE
Ereg_replace () preg_replace ()
Ereg () preg_match ()
Eregi_replace () preg_replace ()
Eregi () preg_match ()
Split () preg_split ()
Spliti () preg_split ()
SQL _regcase () no peering function