I'm not sure if this is possible with a regex. I will try to use the regex, but if this is not possible, I will switch to double check.
My database (postgresql) accepts decimal as 15.6 (maximum 15 digits with maximum six decimal places), so if I have 10 integer digits, I can have 5 decimal digits. The decimal separator is ignored.
I am currently using this regex (Comma is the decimal separator):
^\d{1,15}(\,\d{1,6})?$
It does not check the total length, but only the numbers on the left. But since the user can also enter dots (thousands separators), I have this monster:
^((\d+)|(\d{1,3}(\.\d{3})+)|(\d{1,3}(\.\d{3})(\,\d{3})+))((\,\d{4})|(\,\d{3})|(\,\d{2})|(\,\d{1})|(\,))?$
It does not accept more than three decimal places. I can edit this to accept 6 decim, but I still can’t check the total length.
Can I check the total number length? Ignoring dots and semicolons.
The regular expression should take:
1234567890,123456
1.234.567.890,123456
And of course, any other averages:
1.234,12 , 1,0 , 1 ...
source share