Reputation: 117
Can you suggest a javascript regex to check the number format 1.00.999,000
here '.' represents 100's and ',' represents decimal points.
Upvotes: 1
Views: 352
Reputation: 68790
This will works for number with or without decimals (3 max)
[0-9]{1,2}(\.[0-9]{3})*(,[0-9]{1,3})?
Upvotes: 1
Reputation: 9752
If your just asking for a number format for your exact match then
1.00.999,000 becomes [0-9]\.[0-9]{2}.[0-9]{3},[0-9]{3}
What I suspect you really want may be
[0-9]{0,2}(.[0-9]{3})+,[0-9]{0,3}
so two numbers
, followed by any amount of dot three number
followed by , between 0 and 3 numbers
. I could be wrong in interpreting the number format but I suspect your example of 1.00.999,000
should have an extra zero in the first grouping from the left (000 instead of 00) to make it uniform with the sample after it, or drop the dot between the 1.00.
Upvotes: 3