php - how to match numbers with dash or space in between -


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

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -