I want user only input 0-9 and only once \".\"
patt = /[^0-9(.{1})]/ 1.2222 -> true 1.2.2 -> false (only once \'.\')
help me , t
This regex:
\d*(?:\.\d+)?
will give results:
123 -> true 123.345 -> true 123. -> true .345 -> true 0.3345 -> true
However, you must check emptiness of the input before using it because the regex also permit zero-length input.