Date: 07/31/00
- Next message: Egon Schmid: "[PHP-DOC] cvs: phpdoc /en/functions pcre.xml"
- Previous message: Monte Ohrt: "[PHP-DOC] cvs: phpdoc /en/functions pcre.xml"
- Next in thread: Egon Schmid: "[PHP-DOC] cvs: phpdoc /en/functions pcre.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
mohrt Mon Jul 31 09:11:27 2000 EDT
Modified files:
/phpdoc/en/functions pcre.xml
Log:
update preg_split() and preg_quote examples
Index: phpdoc/en/functions/pcre.xml
diff -u phpdoc/en/functions/pcre.xml:1.24 phpdoc/en/functions/pcre.xml:1.25
--- phpdoc/en/functions/pcre.xml:1.24 Mon Jul 31 08:51:13 2000
+++ phpdoc/en/functions/pcre.xml Mon Jul 31 09:11:27 2000
@@ -474,13 +474,10 @@
<example>
<title>Getting parts of search string</title>
<programlisting role="php">
+// split the phrase by any number of commas or space characters,
+// which include " ", \r, \t, \n and \f
$keywords = preg_split ("/[\s,]+/", "hypertext language, programming");
</programlisting>
- <para>
- This example splits the text by any number of spaces or
- commas. So the resulting $keywords array would be ("hypertext",
- "language", "programming")
- </para>
</example>
See also <function>preg_match</function>,
<function>preg_match_all</function>, and
@@ -533,19 +530,17 @@
<example>
<title>Italicizing a word within some text</title>
<programlisting role="php">
+
+// In this example, preg_quote($word) is used to keep the
+// asterisks from having special meaning to the regular
+// expression.
+
$textbody = "This book is *very* difficult to find.";
$word = "*very*";
-$textbody = preg_replace ("|\b".preg_quote($word)."\b|",
+$textbody = preg_replace ("/".preg_quote($word)."/",
"<i>".$word."</i>",
$textbody);
</programlisting>
- <para>
- In this example, preg_quote($word) is used to keep the
- asterisks from having special meaning to the regular
- expression. The \b is recognized by pcre to find a word
- boundary, so only whole words match. This way something like
- "is*very*difficult" would not be considered a match.
- </para>
</example>
</para>
</refsect1>
@@ -577,8 +572,9 @@
<example>
<title><function>preg_grep</function> example</title>
<programlisting role="php">
-preg_grep ("/^(\d+)?\.\d+$/", $array); // find all array elements
- // containing floating point numbers
+// return all array elements
+// containing floating point numbers
+$fl_array = preg_grep ("/^(\d+)?\.\d+$/", $array);
</programlisting>
</example>
</para>
- Next message: Egon Schmid: "[PHP-DOC] cvs: phpdoc /en/functions pcre.xml"
- Previous message: Monte Ohrt: "[PHP-DOC] cvs: phpdoc /en/functions pcre.xml"
- Next in thread: Egon Schmid: "[PHP-DOC] cvs: phpdoc /en/functions pcre.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

