Regex for number format

0

How can I create a regex (which will be used with preg_match ) for the following format 1.123,12 ?

    
asked by anonymous 27.06.2016 / 18:05

1 answer

1

Pattern to get numbers from 0 to 9,999,999.99: " ((?:\d\.)?(?:\d{1,3}\.)?\d{1,3},\d{1,2})|(\d) "

pattern above gets numbers in the following formats:

  • 0
  • 0.00
  • 00,00
  • 0.000,00
  • 000,000.00
  • 0.000.000,00

Example on Regex101 .

I believe that you should have better ways to resolve this without regex , but I know little of php .

    
28.06.2016 / 19:41