I want A regular Expression to validate this input of numeric(3,2)
like 2.00 , 7.96 or 9.27
What Should I try ?
I want A regular Expression to validate this input of numeric(3,2)
like 2.00 , 7.96 or 9.27
What Should I try ?
^\d\.\d{2}$
This one will match the number EXACTLY in the format where is one digit before dot and two digits after it.
^\d+\.\d{2}$
This one will match the number, where is an arbitrary number of digits before the dot and two digits after it.
^\d+\.\d+$
This one will match the number, where the number of digits before and after the dot is completely arbitrary.
^ - beginning of a line
$ - end of a line
+ - the preceding symbol must occur once or more times
\d - a decimal number
. - the escaped dot symbol - otherwise it's a special character
^\d+?\.\d{2}$
This will look for d.dd where the first d is optional (if they enter just .12 for example). The $ at the end indicates the end of the string, so if they start typing letters or additional characters at the end of the string it won't match and you can throw an error for invalid input.