svn: /phpdoc/en/trunk/reference/pcre/functions/ preg-match.xml
| From: | Torben Wilson | Date: | Sat, 12 Sep 2009 06:55:13 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/pcre/functions/ preg-match.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-4909@lists.php.net to get a copy of this message | ||
torben Sat, 12 Sep 2009 06:55:13 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=288276
Log:
Document that since PHP 5.2.2, named subpatterns accept the syntax
(?<name>) and (?'name') as well as the older (?P<name>).
Addresses bug #46904.
Bug: http://bugs.php.net/46904 (Open) preg_match() example
#4 is wrong
Changed paths:
U phpdoc/en/trunk/reference/pcre/functions/preg-match.xml
Modified: phpdoc/en/trunk/reference/pcre/functions/preg-match.xml
===================================================================
--- phpdoc/en/trunk/reference/pcre/functions/preg-match.xml 2009-09-12 06:37:35 UTC (rev 288275)
+++ phpdoc/en/trunk/reference/pcre/functions/preg-match.xml 2009-09-12 06:55:13 UTC (rev 288276)
@@ -175,6 +175,16 @@
</thead>
<tbody>
<row>
+ <entry>5.2.2</entry>
+ <entry>
+ Named subpatterns now accept the
+ syntax <literal>(?<name>)</literal>
+ and <literal>(?'name')</literal> as well
+ as <literal>(?P<name>)</literal>. Previous versions
+ accepted only <literal>(?P<name>)</literal>.
+ </entry>
+ </row>
+ <row>
<entry>4.3.3</entry>
<entry>
The <parameter>offset</parameter> parameter was added
@@ -275,8 +285,12 @@
$str = 'foobar: 2008';
+// Works in PHP 5.2.2 and later.
preg_match('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
+// Before PHP 5.2.2, use this:
+// preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches);
+
print_r($matches);
?>