php - Regex - Select all numbers without commas -


i have been trying capture numbers in sentence stays follows:

before:

 - 602,135 results   

after:

602135 

i testing following: #\d+# select me 602

ps: had consulted in other posts not solve problem.

you can use preg_replace

try this

$str = '- 602,135 results'; echo $result = preg_replace("/[^0-9]/","",$str); 

output - 602135

you can use same output:-

$result = preg_replace('/\d/', '', $str); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -