正则表达式验证为1-10,但不允许为零 [英] Regular expression validation for 1-10 but not allowed zero
本文介绍了正则表达式验证为1-10,但不允许为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
具有^ [1-9] {1,6} $正则表达式仅允许1到9位数字.我想要一个表达式,不允许数字为零,但允许值10-10,数字为10、20、30,但允许用户输入"0".
having ^[1-9]{1,6}$ regular expression allowed only 1 to 9 digit. i want expression that not allowed zero in digit but allowed 10,20,30 in value 1-10 digit allowed but user put "0" not allowed.
推荐答案
常规表达式只允许使用1到9位数字.我想要一个表达式,该值不允许为零,但允许值10-10,允许为10、20、30,但允许用户输入"0".
regular expression allowed only 1 to 9 digit. i want expression that not allowed zero in digit but allowed 10,20,30 in value 1-10 digit allowed but user put "0" not allowed.
尝试:
^[1-9][0-9]{0,5}
这篇关于正则表达式验证为1-10,但不允许为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文