Friday, 6 September 2013

How to grab all regex matches in php?

How to grab all regex matches in php?

$pattern = '/b+[^\s-]*/';
$subject = 'brew and this is bunny';
preg_match($pattern, $subject, $matches);
Clearly, brew and bunny should match, but $matches only contains brew.
What should I do to have $matches contain all regex matches

No comments:

Post a Comment