Guest User

Untitled

a guest
Dec 13th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. $list = [
  2. '3928.3939392', // Should not be matched
  3. '4.239,99',
  4. '39',
  5. '3929',
  6. '2993.39',
  7. '393993.999'
  8. ];
  9.  
  10. foreach($list as $str){
  11. preg_match('/^(?<![d.,])-?d{1,3}(?:[,. ]?d{3})*(?:[^.,%]|[.,]d{1,2})-?(?![d.,%]|(?: %))$/', $str, $matches);
  12. print_r($matches);
  13. }
  14.  
  15. Array
  16. (
  17. [0] => 3928.3939392
  18. )
  19. Array
  20. (
  21. [0] => 4.239,99
  22. )
  23. Array
  24. (
  25. [0] => 39
  26. )
  27. Array
  28. (
  29. [0] => 3929
  30. )
  31. Array
  32. (
  33. [0] => 2993.39
  34. )
  35. Array
  36. (
  37. )
Add Comment
Please, Sign In to add comment