CVS update: php3/doc/functions

From: Date: Fri, 28 May 1999 13:06:20 +0000
Subject: CVS update: php3/doc/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-6155@lists.php.net to get a copy of this message
Date: Friday May 28, 1999 @ 9:06 Author: andrey Update of /repository/php3/doc/functions In directory php:/tmp/php3/doc/functions Modified Files: pcre.sgml Log Message: More docs. Index: php3/doc/functions/pcre.sgml diff -u php3/doc/functions/pcre.sgml:1.2 php3/doc/functions/pcre.sgml:1.3 --- php3/doc/functions/pcre.sgml:1.2 Thu May 27 17:32:32 1999 +++ php3/doc/functions/pcre.sgml Fri May 28 09:06:20 1999 @@ -12,33 +12,33 @@ Perl. The expression should be enclosed in the delimiters, a forward slash (/), for example. Any character can be used for delimiter as long as it's not alphanumeric or backslash (\). If - the delimiter character has to be used in the pattern, it needs - to be escaped by backslash. + the delimiter character has to be used in the expression itself, + it needs to be escaped by backslash. <para> The ending delimiter may be followed by various options that affect the matching. i, m, s, and x options have the same effect as they do in Perl. There are also some upper case options that Perl doesn't - have. /A, /E, /U, and /X set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, + have. A, E, U, and X set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, PCRE_UNGREEDY, and PCRE_EXTRA respectively. The result of these options is explained in more detail in PCRE manual. <para> - /S option can be specified to make the library analyze the pattern + S option can be specified to make the library analyze the pattern a bit more carefully. This is mainly useful when many searches using the same pattern need to be performed, and the pattern is not anchored and does not have a single fixed starting character. - <informalexample> + <example> <title>Examples of valid patterns</title> <itemizedlist> - <listitem><simpara>/<\/\w+>/</listitem> + <listitem><simpara>/<\\/\\w+>/</listitem> <listitem><simpara>|(\d{3})-\d+|Sm</listitem> <listitem><simpara>/^(?i)php[34]/</listitem> </itemizedlist> </informalexample> - <informalexample> + <example> <title>Examples of invalid patterns</title> <itemizedlist> <listitem><simpara>/href='(.*)' - missing ending delimiter</listitem> @@ -60,8 +60,7 @@ <funcdef>int <function>preg_match</function></funcdef> <paramdef>string <parameter>pattern</parameter></paramdef> <paramdef>string <parameter>subject</parameter></paramdef> - <paramdef>array <parameter><optional>matches</optional></parameter> - </paramdef> + <paramdef>array <parameter><optional>matches</optional></parameter></paramdef> </funcsynopsis> <para> Searches <parameter>subject</parameter> for a match to the regular @@ -89,8 +88,9 @@ </programlisting> </example> - See also <function>preg_match_all</function>, <function>preg_replace - </function>, and <function>preg_split</function>. + See also <function>preg_match_all</function>, + <function>preg_replace</function>, and + <function>preg_split</function>. </refsect1> </refentry> @@ -106,8 +106,7 @@ <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> + <paramdef>int <parameter><optional>order</optional></parameter></paramdef> </funcsynopsis> <para> Searches <parameter>subject</parameter> for all matches to the regular @@ -183,8 +182,23 @@ </variablelist> <para> + If <parameter>order</parameter> is not specified, it is assumed + to be PREG_PATTERN_ORDER. + + <para> Returns true is any match is found, or false if no match is found or an error occurred. + + <example> + <title>Getting all phone numbers out of some text.</title> + <programlisting> +preg_match_all("/\\(? (\\d{3})? \\)? (?(1) [\\-\\s] ) \\d{3}-\\d{4}/x", "Call 555-1212 or 1-800-555-1212", $phones); + </programlisting> + </example> + + <simpara> + See also <function>preg_match</function>, <function>preg_replace + </function>, and <function>preg_split</function>. </refsect1> </refentry> @@ -199,8 +213,7 @@ <funcdef>mixed <function>preg_replace</function></funcdef> <paramdef>mixed <parameter>pattern</parameter></paramdef> <paramdef>mixed <parameter>replacement</parameter></paramdef> - <paramdef>mixed <parameter>subject</parameter> - </paramdef> + <paramdef>mixed <parameter>subject</parameter></paramdef> </funcsynopsis> <para> Searches <parameter>subject</parameter> for matches to <parameter> @@ -248,7 +261,6 @@ </programlisting> </example> - <para> This example will produce: <informalexample> @@ -257,8 +269,44 @@ </programlisting> </informalexample> - See also <function>preg_match</function>, <function>preg_match_all - </function>, and <function>preg_split</function>. + See also <function>preg_match</function>, + <function>preg_match_all</function>, and + <function>preg_split</function>. + </refsect1> + </refentry> + + <refentry id="function.preg-split"> + <refnamediv> + <refname>preg_split</refname> + <refpurpose>Split string by a regular expression</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>array preg_split</funcdef> + <paramdef>string <parameter>pattern</parameter></paramdef> + <paramdef>string <parameter>subject</parameter></paramdef> + <paramdef>int <parameter><optional>limit</optional></parameter></paramdef> + </funcsynopsis> + <para> + Returns an array containing substrings of <parameter>subject</parameter> + split along boundaries matched by <parameter>pattern</parameter>. + + <para> + If <parameter>limit</parameter> is specified, then only substrings + up to <parameter>limit</parameter> are returned. + + <para> + <example> + <title>Getting parts of search string</title> + <programlisting> +$keywords = preg_split("/[\\s,]+/", "hypertext language, programming"); + </programlisting> + </example> + + See also <function>preg_match</function>, + <function>preg_match_all</function>, and + <function>preg_replace</function>. </refsect1> </refentry> </reference> -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#6155) next »