I would have thought this would be fairly common, but haven't found a solution
What I would like is a regular expression that fails on a set number of significant figures (a Max), but passes for less than the Max. I would like it to work with both dot or comma (french) decimal separators.
So for 15 significant figures, these 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
// should fail:
-1234567890123456
-12345678901234.56
12345678901234.56
123456789012345.60
1.234567890123456
12.34567890123456
123456789012340.6
123456789012300.67
123456789012300000000000.67
10000000000010000000001000010000000001.22
I know I need to use negative look a heads, and I have got close with this so far:
^(?!(?:.*?[1-9]){15,})([-+]?s*d+[.,]?d*?)$
https://regex101.com/r/hQ1rP0/218
but you can see the last few still pass, any pointers?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…