note 78822 deleted from reference.pcre.pattern.syntax by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 08:00:55 +0000 |
| Subject: | note 78822 deleted from reference.pcre.pattern.syntax by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196723@lists.php.net to get a copy of this message | ||
Note Submitter: datacompboy at call2ru dot com
----
For example, you want to cut an some <div> element.
Accurate, from <div> to correspond </div> element.
Here is proof-of-concept code to do this:
<?
$str =
"<dqiv1>1+<div2>2+<div3><b><c>3</c></b></div3>2-</div2>1-</div1>";
preg_match("#<div.> ( ".
" ( (?>[^<]*) ( < ( ([^/d]|d([^i]|i[^v])) | /([^d]|d([^i]|i[^v])) ) )?
)* ".
" | (?R) )* </div.>#xi", $str, $m);
var_dump($m[0]);
?>
it match accurate from <div2> to </div2>. And, if you change <dqiv1> to
<div1>, it will match from <div1> to </div1>