Do you express regular numbers, decimals and commas?

0

Could you help me please, I have this regular expression:

/^\d{1,18}(\.\d{1,2})?$/

The expression accepts numbers and decimals but I want it to also accept commas.

Thanks !!

This is what I want to get

Correct: 10,000.00 Correct: 10.00 Correct: 150,000.00 Correct: 1,000,000.00

Incorrect 10.00

Thank you friends

    
asked by Jonathan Hernandez Lopez 25.05.2018 в 00:27
source

1 answer

0

According to this site this is a Regex that allows you to capture any monetary value with commas and 2 decimal points. :

/^(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/
    
answered by 25.05.2018 / 15:09
source