简体   繁体   English

Javascript正则表达式匹配空字符串,非数字字符或超过1位数的数字?

[英]Javascript regex to match empty strings, non-digit characters or numbers with more than 1 digit?

I'm trying to match empty strings, non-digit characters or numbers with more than 1 digit. 我正在尝试匹配空字符串,非数字字符或超过1位数的数字。

Examples: 例子:

"", "a", "abc", "10"

I tried: 我试过了:

/^([^1-9]*)|(\d{2,})$/

but it doesn't work. 但它不起作用。

您可以使用以下正则表达式:

/^(\d{2,}|[^\d]+|)$/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM