note 92806 deleted from function.preg-match-all by danbrown
| From: | danbrown@php.net | Date: | Mon, 10 Aug 2009 15:33:59 +0000 |
| Subject: | note 92806 deleted from function.preg-match-all by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159272@lists.php.net to get a copy of this message | ||
Note Submitter: MindFreakTheMon
----
royaltm75 at NOSPAM dot gmail dot com, your function is realy useful,
but it fails when in text located more than two self-close elements in a sequence.
For expample:
<link rel="alternate" type="text/html" hreflang="en" href="http://example.org/" />
<link rel="self" type="application/atom+xml" href="http://example.org/feed.atom"/>
Just upgrade the pattern:
<?
'@\<\s*?(\w+)((?:\b(?:\'[^\']*\'|"[^"]*"|[^\>])*)?)
(?:\>((?:(?>[^\<]*)|(?R))*)\<\/\s*?\\1(?:\b[^\>]*)?
\>|\<\s*(\w+)(\b(?:\'[^\']*\'|"[^"]*"|[^\>])*)?\/?\>
|/\>)@uxis'
?>
And use ternary operator to check if $set[3] is set.