Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preg_replace all but digits and . and , [duplicate]

Tags:

I'm trying to preg_replace all but Digits and . and , symbols. From a string,

can be

nksdfojsdfjdsfojdsjofsojdfjo213-9sdfknmcfsjozx -xdcv-cv,1239103

Output using preg_replace or any other solution would return just the numbers and allow for comma and dot signs.

To end up with a1,322.44 as 1,322.44

This is what I tried

$carPrice=preg_replace('/\D/', '', $carPrice); 

Would write three more paragraphs if it is necessary, don't seem to find the answer.