0

我正在使用JqueryValidationEngine在客户端验证我的表单。

我想在表单中使用正则表达式验证文本字段。条件如下

编辑:

条件1:

It should not allow the user to enter single or multiple combinations of zeroes.

E.g. '0', '00,, '00000' etc.

条件2:

It should not allow the user to enter the any multiple digit number starting with 0, but excluding the condition1. 

E.g. '01', '001, '001001' , '000001' etc.

我正在使用rubular.com来检查正则表达式,我需要两个正则表达式来不允许上述两种类型的值。谢谢 :)-

4

3 回答 3

1

条件1(根据OP的建议更新)

/^[1-9]\d*$/ 

条件 2(只有第一个 0 和至少一个非零的数字)

/^0+[1-9][0-9]*$/

上面的倒数

/^((?!^0+[1-9][0-9]*$).)*$/
于 2013-09-24T09:23:49.870 回答
0

条件一:

^\d*[1-9]\d*$

条件二:

^[1-9]\d*$
于 2013-09-24T09:18:32.893 回答
-1
if exp =~ /^[0]+/
  'message 1'
elsif exp =~ /^0[01]*/ 
  'message 2'
end
于 2013-09-24T09:24:06.003 回答