+-

需要一个允许以下有效值的正则表达式.(只允许小数和数字)
有效:
.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
Live Demo
点击查看更多相关文章
转载注明原文:java中的数字和小数的正则表达式 - 乐贴网