note 73298 deleted from function.preg-match-all by bobby
| From: | bobby@php.net | Date: | Fri, 16 Mar 2007 14:45:20 +0000 |
| Subject: | note 73298 deleted from function.preg-match-all by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-124513@lists.php.net to get a copy of this message | ||
Note Submitter: Tromm tom at NOSPAMPLEASE decode uk com
----
Using a capturing group within a group that may occur more than once will only return one
backreference , not one for each occurrance of the entire group.
ie
<?PHP
$example = '<atag>foo</atag><atag>bar</atag>';
$regExp = '/(?:<atag>(.*?)<\/atag>)*/';
preg_match_all($regExp,$example,$matches,PREG_SET_ORDER);
?>
will return
$matches[0][0] = <atag>foo</atag><atag>bar</atag>
$matches[0][1] = bar
foo is lost.
Correct me if I'm wrong. I hope I am.