需要一个允许以下有效值的正则表达式。(只允许小数和数字)
有效:
.1
1.10
1231313
0.32131
31313113.123123123
无效:
dadadd.31232
12313jn123
dshiodah
最佳答案
如果您想严格限制允许的匹配:
^[0-9]*\.?[0-9]+$
解释:
^ # 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
关于java - java中数字和小数的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24974816/