I need a RegEx for a numeric value that starts at 60.00 and has no upper limit.
I have used the below RegEx for numbers between 0.00 and 60.00, but now I need a similar expression for all numbers over 60.00 with 2 decimal places
^(?=.)(?:(?:(?:0|[1-5]?\d)?(?:[,.]\d{1,2})?)|60(?:[.,]00?)?)$
CodePudding user response:
You can use
^(?!60(?:\.00?)?$)(?:[6-9][0-9]|[1-9][0-9]{2,})(?:\.[0-9]{1,2})?$
Or, if you cannot afford lookaheads:
^(?:60(?:\.(?:0?[1-9]|[1-9][0-9]))|(?:6[1-9]|[7-9][0-9]|[1-9][0-9]{2,})(?:\.[0-9]{1,2})?)$
See the regex demo #1 / regex demo #2.
Details:
^
- start of string(?!60(?:\.00?)?$)
- a negative lookahead that fails the match if the string is60
,60.0
or60.00
(?:
- start of a non-capturing group:[6-9][0-9]
-60
to99
number|
- or[1-9][0-9]{2,}
- a digit from1
to9
and then two or more digits (100
and more)
)
- end of the group(?:\.[0-9]{1,2})?
- an optional sequence of a.
and one or two digits$
- end of string.