php - how to match numbers with dash or space in between -
this question has answer here:
i have following regex:
preg_match_all('/(\d+)/', $bio, $matches);
this match consecutive numbers such 1928371921, wanted match following format.
0812-123-1288
or
0812 123 1288
what best way modify above regex handle such cases?
you can use following:
preg_match_all('/\d+(?:[- ]\d+)*/', $bio, $matches);
Comments
Post a Comment