[英]Numbers and Spaces - Loose Phone Regex
How do I test whether a string contains only numbers and spaces using RegEx? 如何使用RegEx测试字符串是否仅包含数字和空格?
ie 即
Pretty loose, but this meets my requirements. 相当宽松,但这符合我的要求。
Suggestions? 建议?
How about /^[\\d ]+$/
? 怎么样
/^[\\d ]+$/
? If it needs to start and end with a digit, /^\\d[\\d ]*\\d$/
should do it. 如果它需要以数字开头和结尾,
/^\\d[\\d ]*\\d$/
应该这样做。
[0-9]
<-- this means any single digit between 0 and 9 [0-9]
< - 这意味着0到9之间的任何单个数字 [0-9 ]
<-- this means any single digit between 0 and 9, or a space [0-9 ]
< - 这意味着0到9之间的任何单个数字或空格 [0-9 ]{1,}
<-- this means any single digit between 0 and 9, or a space, 1 or more times [0-9 ]{1,}
< - 这意味着0到9之间的任何单个数字,或1个或更多个空格 [0-9 ]{1,9}
<-- this means any single digit between 0 and 9, or a space, 1 to 9 times [0-9 ]{1,9}
< - 这意味着0到9之间的任何单个数字,或1到9倍的空格 就像是:
\d*|\s+^[A-Za-z]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.