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

java - How to print docx and pdf? -

qml - Is it possible to implement SystemTrayIcon functionality in Qt Quick application -

java - IntelliJ to move a class along with conflicted classes to a new package? -