本文介绍了允许小数和整数的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好, 我需要编写一个正则表达式,该表达式允许使用这样的数字 1.23 和 1 进入文本框.小数点不是强制. 欢迎任何建议或链接.. !!
Hello everyone, I need to write a regular expression which will allow numbers like 1.23 and 1 in to the text-box. Decimal point is not the compulsion. Any suggestion or links are welcome..!!
推荐答案正则表达式为: ^ [0-9] \ d {0,9}(\. \ d {1,3})?%? Regular Expression is : ^[0-9]\d{0,9}(\.\d{1,3})?%?
[0-9]:用于允许从0到9的整数的整数 d {0,9}:最多需要10位数字 \. :十进制 d {1,3}:十进制最多三位数字 [0-9] : for integers which allows integers from 0 to 9 d{0,9}: this will take up to 10 digits \. : for decimal d{1,3} : for decimal up to three digits
范围为1-9的数字,后跟零个或多个其他数字: A digit in the range 1-9 followed by zero or more other digits: ^[1-9]\d*
更多推荐
允许小数和整数的正则表达式
发布评论