mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
added example to preg_match_all()
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@28669 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
1c6012e384
commit
74466adb74
1 changed files with 29 additions and 0 deletions
|
@ -225,6 +225,35 @@ preg_match_all ("/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x",
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Find matching HTML tags (greedy)</title>
|
||||
<programlisting role="php">
|
||||
$html = "<b>bold text<b>lt;a href=howdy.html>click me<a>
|
||||
|
||||
preg_match_all("/(<w]+)[^>lt;2> $html, $matches);
|
||||
|
||||
for($i=0; $i< 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: <b>bold text<b>
|
||||
part 1: <b>
|
||||
part 2: bold text
|
||||
part 3: <b>
|
||||
|
||||
matched: <a href=howdy.html>click me<a>
|
||||
part 1: <a href=howdy.html>
|
||||
part 2: click me
|
||||
part 3: <a>
|
||||
</programlisting>
|
||||
</para>
|
||||
<simpara>
|
||||
See also <function>preg_match</function>,
|
||||
<function>preg_replace</function>,
|
||||
|
|
Loading…
Reference in a new issue