Tuesday, 17 September 2013

preg_match_all get last match

preg_match_all get last match

Is it possible to get the last match using preg_match_all? Using this
regex will only return 126 81 and that's not what I'm after. In this case
I want 183 34 to be returned.
$string = 'Korpstigen 126 183 34 Kalmar';
preg_match_all("/[0-9]{5}|[0-9]{3} [0-9]{2}/", $string, $matches,
PREG_OFFSET_CAPTURE);

No comments:

Post a Comment