I have been searching for a solution to what I thought was a common problem but haven't found one yet.
What I need is a regular expression that will fail on a specific number of significant figures (a Max), but pass for fewer than the Max. It should also work with both dot or comma (French) decimal separators.
For 15 significant figures, the following values should pass:
0
0.00
1
-1
1.23456789012345
10.2345678901234
12.3456789012345
-123.4
-12.34
-1,33
-1.33
-123456789012345
-1234567890123450
-12345678901234.50
12345678901234.50
123456789012345.00
// These values should fail:
-1234567890123456
-12345678901234.56
12345678901234.56
123456789012345.60
1.234567890123456
12.34567890123456
123456789012340.6
123456789012300.67
123456789012300000000000.67
10000000000010000000001000010000000001.22
I understand that I need to use negative lookaheads and have come close with this so far:
^(?!(?:.*?[1-9]){15,})([-+]?\s*\d+[\.\,]?\d*?)$
https://regex101.com/r/hQ1rP0/218
However, as you can see, the last few still pass. Any suggestions?