From 378c28cc339ea6e38c864948777c3bc25d860ed6 Mon Sep 17 00:00:00 2001 From: Monte Ohrt Date: Mon, 31 Jul 2000 15:31:46 +0000 Subject: [PATCH] update preg_match_all() example git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@29413 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/pcre.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/pcre.xml b/functions/pcre.xml index ba14dee679..b120037a7f 100644 --- a/functions/pcre.xml +++ b/functions/pcre.xml @@ -248,6 +248,9 @@ preg_match_all ("/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x", Find matching HTML tags (greedy) +// the \\2 is an example of backreferencing. This tells pcre that +// it must match the 2nd set of parenthesis in the regular expression +// itself, which would be the ([\w]+) in this case. $html = "<b>bold text</b><a href=howdy.html>click me</a> preg_match_all ("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/", $html, $matches);