Need a regex that allows the following valid values.(only decimals and numbers are allowed)
valid :
.1
1.10
1231313
0.32131
31313113.123123123
Invalid :
dadadd.31232
12313jn123
dshiodah
If you want to be strict on your allowed matches:
^[0-9]*\.?[0-9]+$
Explanation:
^ # the beginning of the string
[0-9]* # any character of: '0' to '9' (0 or more times)
\.? # '.' (optional)
[0-9]+ # any character of: '0' to '9' (1 or more times)
$ # before an optional \n, and the end of the string
Live Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With