diff --git a/language-snippets.ent b/language-snippets.ent index 730336b920..a433547710 100644 --- a/language-snippets.ent +++ b/language-snippets.ent @@ -10,7 +10,8 @@ number generator is seeded automatically.'> As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function -will issue an E_DEPRECATED notice.'> +will issue an E_DEPRECATED notice. See the list of +differences for help on converting to PCRE.'> This function is binary-safe.'> diff --git a/reference/pcre/pattern.posix.xml b/reference/pcre/pattern.posix.xml new file mode 100644 index 0000000000..4125b71521 --- /dev/null +++ b/reference/pcre/pattern.posix.xml @@ -0,0 +1,113 @@ + + +
+ Differences from POSIX regex + + + As of PHP 5.3.0, the POSIX Regex extension + is deprecated. There are a number of differences between POSIX regex and + PCRE regex. This page lists the most notable ones that are necessary to + know when converting to PCRE. + + + + + + + The PCRE functions require that the pattern is enclosed by delimiters. + + + + + Unlike POSIX, the PCRE extension does not have dedicated functions for + case-insensitive matching. Instead, this is supported using the /i pattern modifier. Other + pattern modifiers are also available for changing the matching strategy. + + + + + The POSIX functions find the longest of the leftmost match, but PCRE + stops on the first valid match. If the string doesn't match at all it + makes no difference, but if it matches it may have dramatic effects on + both the resulting match and the matching speed. + + + To illustrate this difference, consider the following example from + "Mastering Regular Expressions" by Jeffrey Friedl. Using the pattern + one(self)?(selfsufficient)? on the string + oneselfsufficient with PCRE will result in matching + oneself, but using POSIX the result will be the full + string oneselfsufficient. Both (sub)strings match the + original string, but POSIX requires that the longest be the result. + + + + + + + + Function replacements + + + + POSIX + PCRE + + + + + ereg_replace + preg_replace + + + ereg + preg_match + + + eregi_repalce + preg_replace + + + eregi + preg_match + + + split + preg_split + + + spliti + preg_split + + + sql_regcase + No equivalent + + + +
+
+
+ + diff --git a/reference/pcre/pattern.xml b/reference/pcre/pattern.xml index 04b9f8d128..f73cd04060 100644 --- a/reference/pcre/pattern.xml +++ b/reference/pcre/pattern.xml @@ -6,6 +6,7 @@ &reference.pcre.pattern.modifiers; &reference.pcre.pattern.differences; + &reference.pcre.pattern.posix; &reference.pcre.pattern.syntax;