svn: /phpdoc/en/trunk/reference/pcre/functions/ preg-match-all.xml preg-match.xml
| From: | Jordi Boggiano | Date: | Thu, 17 Dec 2009 12:28:26 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/pcre/functions/ preg-match-all.xml preg-match.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-5675@lists.php.net to get a copy of this message | ||
seld Thu, 17 Dec 2009 12:28:26 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=292248
Log:
Emphasize the use of ?P<> for named sub-patterns instead of the backwards incompatible
?<>. Fixes bug #50306 - refs bug #46904
Bugs: http://bugs.php.net/50306 (Open) preg_match_all()
example #3 is wrong
http://bugs.php.net/46904 (Closed) preg_match()
example #4 is wrong
Changed paths:
U phpdoc/en/trunk/reference/pcre/functions/preg-match-all.xml
U phpdoc/en/trunk/reference/pcre/functions/preg-match.xml
Modified: phpdoc/en/trunk/reference/pcre/functions/preg-match-all.xml
===================================================================
--- phpdoc/en/trunk/reference/pcre/functions/preg-match-all.xml 2009-12-17 12:10:36 UTC (rev 292247)
+++ phpdoc/en/trunk/reference/pcre/functions/preg-match-all.xml 2009-12-17 12:28:26 UTC (rev 292248)
@@ -162,7 +162,7 @@
</para>
<note>
<para>
- Using <parameter>offset</parameter> is not equivalent to passing
+ Using <parameter>offset</parameter> is not equivalent to passing
<literal>substr($subject, $offset)</literal> to
<function>preg_match_all</function> in place of the subject string,
because <parameter>pattern</parameter> can contain assertions such as
@@ -198,6 +198,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
@@ -285,8 +295,12 @@
c: 3
FOO;
-preg_match_all('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
+preg_match_all('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches);
+/* This also works in PHP 5.2.2 (PCRE 7.0) and later, however
+ * the above form is recommended for backwards compatibility */
+// preg_match_all('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
+
print_r($matches);
?>
Modified: phpdoc/en/trunk/reference/pcre/functions/preg-match.xml
===================================================================
--- phpdoc/en/trunk/reference/pcre/functions/preg-match.xml 2009-12-17 12:10:36 UTC (rev 292247)
+++ phpdoc/en/trunk/reference/pcre/functions/preg-match.xml 2009-12-17 12:28:26 UTC (rev 292248)
@@ -87,7 +87,7 @@
</para>
<note>
<para>
- Using <parameter>offset</parameter> is not equivalent to passing
+ Using <parameter>offset</parameter> is not equivalent to passing
<literal>substr($subject, $offset)</literal> to
<function>preg_match</function> in place of the subject string,
because <parameter>pattern</parameter> can contain assertions such as
@@ -286,11 +286,11 @@
$str = 'foobar: 2008';
-// Works in PHP 5.2.2 and later.
-preg_match('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
+preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches);
-// Before PHP 5.2.2, use this:
-// preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches);
+/* This also works in PHP 5.2.2 (PCRE 7.0) and later, however
+ * the above form is recommended for backwards compatibility */
+// preg_match('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
print_r($matches);