fork(2) download
  1. <?php
  2. $input = "textmdwrhfejhg../,2222233333,34erw.re.ty";
  3. //cut numbers after comma if there are any, after 2 digits
  4. $matchPattern = '/[0-9]+(?:\,[0-9]{2}){0,2}/';
  5. //remove everything except numbers, commas and dots
  6. $repl1 = trim(preg_replace("/[^0-9,.]/", "", $input), ".,");
  7. //let there be a 0 before comma to have values like 0,75, remove the 0
  8. $repl2 = preg_replace("/^0/", "",$repl1);
  9. //now i need you here to help me for the expression putting dots after each 3 numbers, until the comma:
  10. $repl3 = preg_replace('/(\d)(?=(?:\d{3})+(?!\d))/', '$1.', $repl2);
  11. echo "$repl3" . "\n";
  12.  
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
2.222.233.333,34