CVS update: php3/doc/functions
| From: | andrey | Date: | Sun, 30 May 1999 15:04:20 +0000 |
| Subject: | CVS update: php3/doc/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6306@lists.php.net to get a copy of this message | ||
Date: Sunday May 30, 1999 @ 11:04
Author: andrey
Update of /repository/php3/doc/functions
In directory php:/tmp/cvs-serv29522/doc/functions
Modified Files:
pcre.sgml
Log Message:
Make formatting a bit nicer.
Index: php3/doc/functions/pcre.sgml
diff -u php3/doc/functions/pcre.sgml:1.5 php3/doc/functions/pcre.sgml:1.6
--- php3/doc/functions/pcre.sgml:1.5 Sat May 29 17:28:50 1999
+++ php3/doc/functions/pcre.sgml Sun May 30 11:04:20 1999
@@ -29,15 +29,17 @@
the same pattern need to be performed, and the pattern is not anchored
and does not have a single fixed starting character.
+ <para>
<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>
</example>
-
+
+ <para>
<example>
<title>Examples of invalid patterns</title>
<itemizedlist>
@@ -77,10 +79,11 @@
found in the subject string, or false if not match was found
or an error occurred.
+ <para>
<example>
<title>Getting the page number out of a string</title>
<programlisting>
-if (preg_match("/page\\s+#(\\d+)/i", "Go to page #9.", $parts))
+if (preg_match("/page\s+#(\d+)/i", "Go to page #9.", $parts))
print "Next page is $parts[1]";
else
print "Page not found.";
@@ -188,16 +191,19 @@
Returns the number of full pattern matches, or false if
no match is found or an error occurred.
+ <para>
<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);
+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>.
+ See also <function>preg_match</function>,
+ <function>preg_replace</function>,
+ and <function>preg_split</function>.
</refsect1>
</refentry>
@@ -223,7 +229,7 @@
<parameter>replacement</parameter> may contain references of the form
<literal>\\<replaceable>n</replaceable></literal>. Every such
reference will be replaced by the text captured by the
- <replaceable>n</replaceable>'th parenthesized pattern. <replaceable>n
+ <replaceable>n</replaceable>'th parenthesized pattern. <replaceable>n
</replaceable>can be from 0 to 99, and <literal>\\0</literal> refers to
the text matched by the whole pattern. Opening parentheses are
counted from left to right (starting from 1) to obtain the number
@@ -253,10 +259,11 @@
<parameter>pattern</parameter>. The converse would not make sense,
though.
+ <para>
<example>
<title>Replacing several values</title>
<programlisting>
-$patterns = array("/(19|20\\d{2})-(\\d{1,2})-(\\d{1,2})/",
"/^\\s*{(\\w+)}\\s*=/");
+$patterns = array("/(19|20\d{2})-(\d{1,2})-(\d{1,2})/", "/^\s*{(\w+)}\s*=/");
$replace = array("\\3/\\4/\\1", "$\\1 =");
print preg_replace($patterns, $replace, "{startDate} = 1999-5-27");
</programlisting>
@@ -264,11 +271,9 @@
This example will produce:
- <informalexample>
- <programlisting>
- $startDate = 5/27/1999
- </programlisting>
- </informalexample>
+ <programlisting>
+ $startDate = 5/27/1999
+ </programlisting>
See also <function>preg_match</function>,
<function>preg_match_all</function>, and
@@ -301,7 +306,7 @@
<example>
<title>Getting parts of search string</title>
<programlisting>
-$keywords = preg_split("/[\\s,]+/", "hypertext language, programming");
+$keywords = preg_split("/[\s,]+/", "hypertext language, programming");
</programlisting>
</example>
--
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