diff --git a/functions/pcre.xml b/functions/pcre.xml
index b6404f5921..8d0351e3be 100644
--- a/functions/pcre.xml
+++ b/functions/pcre.xml
@@ -474,13 +474,10 @@ $text = preg_replace ($search, $replace, $document);
Getting parts of search string
+// 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");
-
- This example splits the text by any number of spaces or
- commas. So the resulting $keywords array would be ("hypertext",
- "language", "programming")
-
See also preg_match,
preg_match_all, and
@@ -533,19 +530,17 @@ echo $keywords; // returns \$40 for a g3\/400
Italicizing a word within some text
+
+// 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);
-
- 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.
-
@@ -577,8 +572,9 @@ $textbody = preg_replace ("|\b".preg_quote($word)."\b|",
preg_grep example
-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);