php - Regex - Select all numbers without commas -
this question has answer here:
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
Post a Comment