svn: /phpdoc/en/trunk/reference/pcre/ pattern.syntax.xml
| From: | Daniel Egeberg | Date: | Wed, 28 Jul 2010 08:18:50 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/pcre/ pattern.syntax.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-6934@lists.php.net to get a copy of this message | ||
degeberg Wed, 28 Jul 2010 08:18:50 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=301647
Log:
Fixed up some formatting. Removed obsolete inline PHP 4 changelog info.
Changed paths:
U phpdoc/en/trunk/reference/pcre/pattern.syntax.xml
Modified: phpdoc/en/trunk/reference/pcre/pattern.syntax.xml
===================================================================
--- phpdoc/en/trunk/reference/pcre/pattern.syntax.xml 2010-07-28 08:06:25 UTC (rev 301646)
+++ phpdoc/en/trunk/reference/pcre/pattern.syntax.xml 2010-07-28 08:18:50 UTC (rev 301647)
@@ -578,12 +578,11 @@
the <parameter>offset</parameter> argument of
<function>preg_match</function>. It differs from <literal>\A</literal>
when the value of <parameter>offset</parameter> is non-zero.
- It is available since PHP 4.3.3.
</para>
<para>
<literal>\Q</literal> and <literal>\E</literal> can be used to ignore
- regexp metacharacters in the pattern since PHP 4.3.3. For example:
+ regexp metacharacters in the pattern. For example:
<literal>\w+\Q.$.\E$</literal> will match one or more word characters,
followed by literals <literal>.$.</literal> and anchored at the end of
the string.
@@ -603,7 +602,7 @@
<section xml:id="regexp.reference.unicode">
<title>Unicode character properties</title>
<para>
- Since PHP 4.4.0 and 5.1.0, three
+ Since 5.1.0, three
additional escape sequences to match generic character types are available
when <emphasis>UTF-8 mode</emphasis> is selected. They are:
</para>
@@ -635,10 +634,14 @@
letter. In this case, in the absence of negation, the curly brackets in the
escape sequence are optional; these two examples have the same effect:
</para>
- <literallayout>
- \p{L}
- \pL
- </literallayout>
+ <informalexample>
+ <programlisting>
+<![CDATA[
+\p{L}
+\pL
+]]>
+ </programlisting>
+ </informalexample>
<table>
<title>Supported property codes</title>
<tgroup cols="3">
@@ -1167,9 +1170,7 @@
When an option change occurs at top level (that is, not inside
subpattern parentheses), the change applies to the remainder of the
pattern that follows. So <literal>/ab(?i)c/</literal> matches only "abc"
- and "abC". This behaviour has been changed in PCRE 4.0, which is bundled
- since PHP 4.3.3. Before those versions, <literal>/ab(?i)c/</literal> would
- perform as <literal>/abc/i</literal> (e.g. matching "ABC" and
"aBc").
+ and "abC".
</para>
<para>
If an option change occurs inside a subpattern, the effect
@@ -1212,27 +1213,27 @@
which can be nested. Marking part of a pattern as a subpattern
does two things:
</para>
+ <orderedlist>
+ <listitem>
+ <para>
+ It localizes a set of alternatives. For example, the pattern
+ <literal>cat(aract|erpillar|)</literal> matches one of the words "cat",
+ "cataract", or "caterpillar". Without the parentheses, it would match
+ "cataract", "erpillar" or the empty string.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ It sets up the subpattern as a capturing subpattern (as defined above).
+ When the whole pattern matches, that portion of the subject string
+ that matched the subpattern is passed back to the caller via the
+ <emphasis>ovector</emphasis> argument of
<function>pcre_exec</function>.
+ Opening parentheses are counted from left to right (starting from 1) to
+ obtain the numbers of the capturing subpatterns.
+ </para>
+ </listitem>
+ </orderedlist>
<para>
- 1. It localizes a set of alternatives. For example, the
- pattern
-
- <literal>cat(aract|erpillar|)</literal>
-
- matches one of the words "cat", "cataract", or "caterpillar".
- Without the parentheses, it would match "cataract",
- "erpillar" or the empty string.
- </para>
- <para>
- 2. It sets up the subpattern as a capturing subpattern (as
- defined above). When the whole pattern matches, that portion
- of the subject string that matched the subpattern is
- passed back to the caller via the <emphasis>ovector</emphasis>
- argument of
- <function>pcre_exec</function>. Opening parentheses are counted
- from left to right (starting from 1) to obtain the numbers of the
- capturing subpatterns.
- </para>
- <para>
For example, if the string "the red king" is matched against
the pattern
@@ -1265,10 +1266,14 @@
the two patterns
</para>
- <literallayout>
- (?i:saturday|sunday)
- (?:(?i)saturday|sunday)
- </literallayout>
+ <informalexample>
+ <programlisting>
+<![CDATA[
+(?i:saturday|sunday)
+(?:(?i)saturday|sunday)
+]]>
+ </programlisting>
+ </informalexample>
<para>
match exactly the same set of strings. Because alternative
@@ -1279,7 +1284,7 @@
</para>
<para>
- As of PHP 4.3.3, it is possible to name a subpattern using the syntax
+ It is possible to name a subpattern using the syntax
<literal>(?P<name>pattern)</literal>. This subpattern will then
be indexed in the matches array by its normal numeric position and
also by name. PHP 5.2.2 introduced two alternative syntaxes
@@ -1457,8 +1462,7 @@
as many characters as possible and don't return to match the rest of the
pattern. Thus <literal>.*abc</literal> matches "aabc" but
<literal>.*+abc</literal> doesn't because <literal>.*+</literal>
eats the
- whole string. Possessive quantifiers can be used to speed up processing
- since PHP 4.3.3.
+ whole string. Possessive quantifiers can be used to speed up processing.
</para>
<para>
When a parenthesized subpattern is quantified with a minimum
@@ -1855,10 +1859,14 @@
two possible forms of conditional subpattern are
</para>
- <literallayout>
- (?(condition)yes-pattern)
- (?(condition)yes-pattern|no-pattern)
- </literallayout>
+ <informalexample>
+ <programlisting>
+<![CDATA[
+(?(condition)yes-pattern)
+(?(condition)yes-pattern|no-pattern)
+]]>
+ </programlisting>
+ </informalexample>
<para>
If the condition is satisfied, the yes-pattern is used; otherwise
the no-pattern (if present) is used. If there are
@@ -1904,10 +1912,14 @@
the second line:
</para>
- <literallayout>
- (?(?=[^a-z]*[a-z])
- \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} )
- </literallayout>
+ <informalexample>
+ <programlisting>
+<![CDATA[
+(?(?=[^a-z]*[a-z])
+\d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} )
+]]>
+ </programlisting>
+ </informalexample>
<para>
The condition is a positive lookahead assertion that matches
an optional sequence of non-letters followed by a letter. In
@@ -2000,7 +2012,7 @@
</para>
<para>
- Since PHP 4.3.3, <literal>(?1)</literal>, <literal>(?2)</literal> and so
on
+ <literal>(?1)</literal>, <literal>(?2)</literal> and so on
can be used for recursive subpatterns too. It is also possible to use named
subpatterns: <literal>(?P>name)</literal> or
<literal>(?P&name)</literal>.