fork(1) download
  1. <?php
  2. $input = "textmdwrhfejhg../0005456,2222233333,34erw.re.ty";
  3.  
  4. //Here's mine :
  5. $repl1 = preg_replace("/[^0-9,.]/", "", $input);
  6. //following line just removes one zero, i want it to remove all chars like
  7. //Input : 000549,569 Output : 549,569
  8. $repl2 = preg_replace("/^0/", "",$repl1);
  9. $repl3 = str_replace(".","",$repl2);
  10. preg_match('/[0-9]+(?:\,[0-9]{2}){0,2}/', $repl3, $matches);
  11. $repl4 = preg_replace('/(\d)(?=(\d{3})+(?!\d))/', '$1.', $matches[0]);
  12. echo $repl4;
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
0.005.456,22