From 6bdd33b75fdb86ed2f98f8d857afa45b51a4c6fb Mon Sep 17 00:00:00 2001 From: Torben Wilson Date: Sat, 12 Sep 2009 06:55:13 +0000 Subject: [PATCH] Document that since PHP 5.2.2, named subpatterns accept the syntax (?) and (?'name') as well as the older (?P). Addresses bug #46904. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@288276 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/pcre/functions/preg-match.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/reference/pcre/functions/preg-match.xml b/reference/pcre/functions/preg-match.xml index 804246a03c..f2227b23e6 100644 --- a/reference/pcre/functions/preg-match.xml +++ b/reference/pcre/functions/preg-match.xml @@ -174,6 +174,16 @@ Array + + 5.2.2 + + Named subpatterns now accept the + syntax (?<name>) + and (?'name') as well + as (?P<name>). Previous versions + accepted only (?P<name>). + + 4.3.3 @@ -275,8 +285,12 @@ domain name is: php.net $str = 'foobar: 2008'; +// Works in PHP 5.2.2 and later. preg_match('/(?\w+): (?\d+)/', $str, $matches); +// Before PHP 5.2.2, use this: +// preg_match('/(?P\w+): (?P\d+)/', $str, $matches); + print_r($matches); ?>