mfischer Thu Jun 13 03:55:02 2002 EDT Modified files: /phpdoc/en/reference/pcre reference.xml /phpdoc/en/reference/pcre/functions preg-match-all.xml preg-match.xml preg-split.xml Log: - Update to latest PCRE changes. # Would be nice if someone can provide examples for preg_match() and # preg_match_all() with the new PREG_OFFSET_CAPTURE flag.
Index: phpdoc/en/reference/pcre/reference.xml diff -u phpdoc/en/reference/pcre/reference.xml:1.2 phpdoc/en/reference/pcre/reference.xml:1.3 --- phpdoc/en/reference/pcre/reference.xml:1.2 Mon Apr 15 17:57:12 2002 +++ phpdoc/en/reference/pcre/reference.xml Thu Jun 13 03:55:02 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <reference id="ref.pcre"> <title>Regular Expression Functions (Perl-Compatible)</title> <titleabbrev>PCRE</titleabbrev> @@ -58,10 +58,70 @@ <section id="pcre.constants"> <title>Predefined constants</title> <para> - <constant>PREG_PATTERN_ORDER</constant> - <constant>PREG_SET_ORDER</constant> - <constant>PREG_SPLIT_NO_EMPTY</constant> - <constant>PREG_SPLIT_DELIM_CAPTURE</constant> + <table> + <title>PREG constants</title> + <tgroup cols="2"> + <thead> + <row> + <entry>constant</entry> + <entry>description</entry> + </row> + </thead> + <tbody> + <row> + <entry>PREG_PATTERN_ORDER</entry> + <entry> + Orders results so that $matches[0] is an array of full pattern + matches, $matches[1] is an array of strings matched by the first + parenthesized subpattern, and so on. This flag is only used with + <function>preg_match_all</function>. + </entry> + </row> + <row> + <entry>PREG_SET_ORDER</entry> + <entry> + Orders results so that $matches[0] is an array of first set of + matches, $matches[1] is an array of second set of matches, and so + on. This flag is only used with <function>preg_match_all</function>. + </entry> + </row> + <row> + <entry>PREG_OFFSET_CAPTURE</entry> + <entry> + See the description of + <constant>PREG_SPLIT_OFFSET_CAPTURE</constant>. This flag is + available since <literal>PHP</literal> 4.3.0 . + </entry> + </row> + <row> + <entry>PREG_SPLIT_NO_EMPTY</entry> + <entry> + This flag tells <function>preg_split</function> to only return only + non-empty pieces. + </entry> + </row> + <row> + <entry>PREG_SPLIT_DELIM_CAPTURE</entry> + <entry> + This flag tells <function>preg_split</function> to capture + parenthesized expression in the delimiter pattern as well. This flag + is available since <literal>PHP</literal> 4.0.5 . + </entry> + </row> + <row> + <entry>PREG_SPLIT_OFFSET_CAPTURE</entry> + <entry> + If this flag is set, for every occuring match the appendant string + offset will also be returned. Note that this changes the return + value in an array where very element is an array consisting of the + matched string at offset 0 and it's string offset into subject at + offset 1. This flag is available since <literal>PHP</literal> 4.3.0 + and is only used for <function>preg_split</function>. + </entry> + </row> + </tbody> + </tgroup> + </table> </para> </section> @@ -71,10 +131,10 @@ <example> <title>Examples of valid patterns</title> <itemizedlist> - <listitem><simpara>/<\/\w+>/</simpara></listitem> - <listitem><simpara>|(\d{3})-\d+|Sm</simpara></listitem> - <listitem><simpara>/^(?i)php[34]/</simpara></listitem> - <listitem><simpara>{^\s+(\s+)?$}</simpara></listitem> + <listitem><simpara><literal>/<\/\w+>/</literal></simpara></listitem> + <listitem><simpara><literal>|(\d{3})-\d+|Sm</literal></simpara></listitem> + <listitem><simpara><literal>/^(?i)php[34]/</literal></simpara></listitem> + <listitem><simpara><literal>{^\s+(\s+)?$}</literal></simpara></listitem> </itemizedlist> </example> </para> @@ -84,17 +144,17 @@ <itemizedlist> <listitem> <simpara> - /href='(.*)' - missing ending delimiter + <literal>/href='(.*)'</literal> - missing ending delimiter </simpara> </listitem> <listitem> <simpara> - /\w+\s*\w+/J - unknown modifier 'J' + <literal>/\w+\s*\w+/J</literal> - unknown modifier 'J' </simpara> </listitem> <listitem> <simpara> - 1-\d3-\d3-\d4| - missing starting delimiter + <literal>1-\d3-\d3-\d4|</literal> - missing starting delimiter </simpara> </listitem> </itemizedlist> Index: phpdoc/en/reference/pcre/functions/preg-match-all.xml diff -u phpdoc/en/reference/pcre/functions/preg-match-all.xml:1.3 phpdoc/en/reference/pcre/functions/preg-match-all.xml:1.4 --- phpdoc/en/reference/pcre/functions/preg-match-all.xml:1.3 Sun May 12 12:13:12 2002 +++ phpdoc/en/reference/pcre/functions/preg-match-all.xml Thu Jun 13 03:55:02 +2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 --> <refentry id="function.preg-match-all"> <refnamediv> @@ -13,7 +13,7 @@ <methodparam><type>string</type><parameter>pattern</parameter></methodparam> <methodparam><type>string</type><parameter>subject</parameter></methodparam> <methodparam><type>array</type><parameter>matches</parameter></methodparam> - <methodparam choice="opt"><type>int</type><parameter>order</parameter></methodparam> + <methodparam +choice="opt"><type>int</type><parameter>flags</parameter></methodparam> </methodsynopsis> <para> Searches <parameter>subject</parameter> for all matches to the regular @@ -26,7 +26,10 @@ on from end of the last match. </para> <para> - <parameter>order</parameter> can be one of two things: + <parameter>flags</parameter> can be a combination of the following flags + (note that it doesn't make sense to use + <constant>PREG_PATTERN_ORDER</constant> together with + <constant>PREG_SET_ORDER</constant>): <variablelist> <varlistentry> <term>PREG_PATTERN_ORDER</term> @@ -94,11 +97,24 @@ </para> </listitem> </varlistentry> + <varlistentry> + <term>PREG_OFFSET_CAPTURE</term> + <listitem> + <para> + If this flag is set, for every occuring match the appendant string + offset will also be returned. Note that this changes the return + value in an array where every element is an array consisting of the + matched string at offset <literal>0</literal> and it's string offset + into <parameter>subject</parameter> at offset <literal>1</literal>. + This flag is available since <literal>PHP</literal> 4.3.0 . + </para> + </listitem> + </varlistentry> </variablelist> </para> <para> - If <parameter>order</parameter> is not specified, it is assumed - to be PREG_PATTERN_ORDER. + If no order flag is given, <constant>PREG_PATTERN_ORDER</constant> is + assumed. </para> <para> Returns the number of full pattern matches (which might be zero), Index: phpdoc/en/reference/pcre/functions/preg-match.xml diff -u phpdoc/en/reference/pcre/functions/preg-match.xml:1.3 phpdoc/en/reference/pcre/functions/preg-match.xml:1.4 --- phpdoc/en/reference/pcre/functions/preg-match.xml:1.3 Sun May 12 12:13:12 2002 +++ phpdoc/en/reference/pcre/functions/preg-match.xml Thu Jun 13 03:55:02 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 --> <refentry id="function.preg-match"> <refnamediv> @@ -13,6 +13,7 @@ <methodparam><type>string</type><parameter>pattern</parameter></methodparam> <methodparam><type>string</type><parameter>subject</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter>matches</parameter></methodparam> + <methodparam +choice="opt"><type>int</type><parameter>flags</parameter></methodparam> </methodsynopsis> <para> Searches <parameter>subject</parameter> for a match to the regular @@ -24,6 +25,27 @@ matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on. </para> + <para> + <parameter>flags</parameter> can be the following flag: + <variablelist> + <varlistentry> + <term>PREG_OFFSET_CAPTURE</term> + <listitem> + <simpara> + If this flag is set, for every occuring match the appendant string + offset will also be returned. Note that this changes the return value + in an array where every element is an array consisting of the matched + string at offset <literal>0</literal> and it's string offset into + <parameter>subject</parameter> at offset <literal>1</literal>. This + flag is available since <literal>PHP</literal> 4.3.0 . + </simpara> + </listitem> + </varlistentry> + </variablelist> + The <parameter>flags</parameter> parameter is available since + <literal>PHP</literal> 4.3.0 . + </para> + <para> <function>preg_match</function> returns the number of times <parameter>pattern</parameter> matches. That will be either 0 times Index: phpdoc/en/reference/pcre/functions/preg-split.xml diff -u phpdoc/en/reference/pcre/functions/preg-split.xml:1.3 phpdoc/en/reference/pcre/functions/preg-split.xml:1.4 --- phpdoc/en/reference/pcre/functions/preg-split.xml:1.3 Thu May 23 15:34:18 2002 +++ phpdoc/en/reference/pcre/functions/preg-split.xml Thu Jun 13 03:55:02 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 --> <refentry id="function.preg-split"> <refnamediv> @@ -63,10 +63,10 @@ <para> If this flag is set, for every occuring match the appendant string offset will also be returned. Note that this changes the return - value in an array where very element is an array consisting of the + value in an array where every element is an array consisting of the matched string at offset <literal>0</literal> and it's string offset into <parameter>subject</parameter> at offset <literal>1</literal>. - This flag is available since 4.3.0. + This flag is available since <literal>PHP</literal> 4.3.0 . </para> </listitem> </varlistentry>