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

mohrt Thu Jul 20 12:09:09 2000 EDT

  Modified files:
    /phpdoc/en/functions pcre.xml
  Log:
  added example to preg_match_all()
  
  
Index: phpdoc/en/functions/pcre.xml
diff -u phpdoc/en/functions/pcre.xml:1.11 phpdoc/en/functions/pcre.xml:1.12
--- phpdoc/en/functions/pcre.xml:1.11 Thu Jul 20 11:35:38 2000
+++ phpdoc/en/functions/pcre.xml Thu Jul 20 12:09:09 2000
@@ -225,6 +225,35 @@
       </programlisting>
      </example>
     </para>
+ <para>
+ <example>
+ <title>Find matching HTML tags (greedy)</title>
+ <programlisting role="php">
+$html = "&lt;b&gt;bold text&lt;b&gt;lt;a href=howdy.html&gt;click me&lt;a&gt;
+
+preg_match_all("/(&lt;w]+)[^&gt;lt;2&gt; $html, $matches);
+
+for($i=0; $i&lt; count($matches[0]); $i++) {
+echo "matched: ".$matches[0][$i]."\n";
+echo "part 1: ".$matches[1][$i]."\n";
+echo "part 2: ".$matches[3][$i]."\n";
+echo "part 3: ".$matches[4][$i]."\n\n";
+}
+ </programlisting>
+ </example>
+ This example will produce:
+ <programlisting>
+matched: &lt;b&gt;bold text&lt;b&gt;
+part 1: &lt;b&gt;
+part 2: bold text
+part 3: &lt;b&gt;
+
+matched: &lt;a href=howdy.html&gt;click me&lt;a&gt;
+part 1: &lt;a href=howdy.html&gt;
+part 2: click me
+part 3: &lt;a&gt;
+ </programlisting>
+ </para>
     <simpara>
      See also <function>preg_match</function>,
      <function>preg_replace</function>,