[PHP-DEV] CVS update: php3/doc/functions From: andrey (php-dev <email protected>)
Date: 05/27/99

Date: Thursday May 27, 1999 @ 17:32
Author: andrey

Update of /repository/php3/doc/functions
In directory php:/tmp/cvs-serv6642/doc/functions

Modified Files:
        pcre.sgml
Log Message:
More docs.

Index: php3/doc/functions/pcre.sgml
diff -u php3/doc/functions/pcre.sgml:1.1 php3/doc/functions/pcre.sgml:1.2
--- php3/doc/functions/pcre.sgml:1.1 Thu May 27 16:20:17 1999
+++ php3/doc/functions/pcre.sgml Thu May 27 17:32:32 1999
@@ -64,7 +64,7 @@
      </paramdef>
     </funcsynopsis>
     <para>
- Searches <parameter>subject</parameter> for matches to regular
+ Searches <parameter>subject</parameter> for a match to the regular
      expression given in <parameter>pattern</parameter>.
 
     <para>
@@ -89,10 +89,105 @@
       </programlisting>
      </example>
 
- See also <function>preg_match_all</function>.
+ See also <function>preg_match_all</function>, <function>preg_replace
+ </function>, and <function>preg_split</function>.
    </refsect1>
   </refentry>
 
+ <refentry id="function.preg-match-all">
+ <refnamediv>
+ <refname>preg_match_all</refname>
+ <refpurpose>Perform a global regular expression match</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Description</title>
+ <funcsynopsis>
+ <funcdef>int <function>preg_match_all</function></funcdef>
+ <paramdef>string <parameter>pattern</parameter></paramdef>
+ <paramdef>string <parameter>subject</parameter></paramdef>
+ <paramdef>array <parameter>matches</parameter></paramdef>
+ <paramdef>int <parameter><optional>order</optional>
+ </parameter></paramdef>
+ </funcsynopsis>
+ <para>
+ Searches <parameter>subject</parameter> for all matches to the regular
+ expression given in <parameter>pattern</parameter> and puts them in
+ <parameter>matches</parameter> in the order specified by
+ <parameter>order</parameter>.
+
+ <para>
+ After the first match is found, the subsequent searches are continued
+ on from end of the last match.
+
+ <para>
+ <parameter>order</parameter> can be one of two things:
+ <variablelist>
+ <varlistentry>
+ <term>PREG_PATTERN_ORDER</term>
+ <listitem>
+ <para>
+ 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.
+
+ <informalexample>
+ <programlisting>
+preg_match_all("|&lt;[^>]+>(.*)&lt;/[^>]+>|U", "&lt;div align=left>a test&lt;/div>", $out, PREG_PATTERN_ORDER);
+print $out[0][0].", ".$out[0][1]."\n";
+print $out[1][0].", ".$out[1][1]."\n"
+ </programlisting>
+ </informalexample>
+
+ This example will produce:
+ <informalexample>
+ <programlisting>
+&lt;b>example: &lt/b>, &lt;div align=left>this is a test&lt;/div>
+example: , this is a test
+ </programlisting>
+ </informalexample>
+
+ So, $out[0] contains array of strings that matched full pattern,
+ and $out[1] contains array of strings enclosed by tags.
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>PREG_SET_ORDER</term>
+ <listitem>
+ <para>
+ 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.
+
+ <informalexample>
+ <programlisting>
+preg_match_all("|&lt;[^>]+>(.*)&lt;/[^>]+>|U", "&lt;div align=left>a test&lt;/div>", $out, PREG_SET_ORDER);
+print $out[0][0].", ".$out[0][1]."\n";
+print $out[1][0].", ".$out[1][1]."\n"
+ </programlisting>
+ </informalexample>
+
+ This example will produce:
+ <informalexample>
+ <programlisting>
+&lt;b>example: &lt;/b>, example:
+&lt;div align=left>this is a test&lt;/div>, this is a test
+ </programlisting>
+ </informalexample>
+
+ In this case, $matches[0] is the first set of matches, and
+ $matches[0][0] has text matched by full pattern, $matches[0][1]
+ has text matched by first subpattern and so on. Similarly,
+ $matches[1] is the second set of matches, etc.
+ </listitem>
+ </varlistentry>
+ </variablelist>
+
+ <para>
+ Returns true is any match is found, or false if no match is found
+ or an error occurred.
+ </refsect1>
+ </refentry>
+
   <refentry id="function.preg-replace">
    <refnamediv>
     <refname>preg_replace</refname>
@@ -161,6 +256,9 @@
        $startDate = 5/27/1999
       </programlisting>
      </informalexample>
+
+ See also <function>preg_match</function>, <function>preg_match_all
+ </function>, and <function>preg_split</function>.
    </refsect1>
   </refentry>
 </reference>

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>