[PHP-DOC] cvs: phpdoc /en/functions pcre.xml From: Monte Ohrt (monte <email protected>)
Date: 07/28/00

mohrt Fri Jul 28 14:27:09 2000 EDT

  Modified files:
    /phpdoc/en/functions pcre.xml
  Log:
  added some examples to preg_match()
  
  
Index: phpdoc/en/functions/pcre.xml
diff -u phpdoc/en/functions/pcre.xml:1.21 phpdoc/en/functions/pcre.xml:1.22
--- phpdoc/en/functions/pcre.xml:1.21 Fri Jul 28 13:19:08 2000
+++ phpdoc/en/functions/pcre.xml Fri Jul 28 14:27:09 2000
@@ -90,12 +90,30 @@
 
     <para>
      <example>
- <title>Getting the page number out of a string</title>
+ <title>find the string of text "php"</title>
       <programlisting role="php">
-if (preg_match ("/page\s+#(\d+)/i", "Go to page #9.", $parts)) {
- print "Next page is $parts[1]";
+// the "i" after the pattern delimiter indicates a case-insensitive search
+if (preg_match ("/php/i", "PHP is the web scripting language of choice.")) {
+ print "A match was found.";
 } else {
- print "Page not found.";
+ print "A match was not found.";
+}
+ </programlisting>
+ </example>
+ <example>
+ <title>find the word "web"</title>
+ <programlisting role="php">
+// the \b in the pattern indicates a word boundary, so only the distinct
+// word "web" is matched, and not a word partial like "webbing" or "cobweb"
+if (preg_match ("/\bweb\b/i", "PHP is the web scripting language of choice.")) {
+ print "A match was found.";
+} else {
+ print "A match was not found.";
+}
+if (preg_match ("/\bweb\b/i", "PHP is the website scripting language of choice.")) {
+ print "A match was found.";
+} else {
+ print "A match was not found.";
 }
       </programlisting>
      </example>