I'm trying to write a regular expression
that says first letter not to be uppercase and the rest 0-19 characters mixed case. This doesn't seem to do it.
!/^[A-Z][a-zA-Z]{0,19}$/
I'm trying to write a regular expression
that says first letter not to be uppercase and the rest 0-19 characters mixed case. This doesn't seem to do it.
!/^[A-Z][a-zA-Z]{0,19}$/
如果你想要第一个字母小写,所有其他小写或大写,你可以这样做:
/^[a-z][a-zA-Z]{0,19}$/
请注意,您不能只说[^A-Z]
,因为这将允许非字母字符通过,例如数字。
许多解决方案之一是正则表达式模式
/^(?![A-Z])[a-zA-Z]{1,20}$/
...内容为:一到二十个字母,前面没有大写
更改自:
!/^[A-Z][a-zA-Z]{0,19}$/
至:
/^[^A-Z][a-zA-Z]{0,19}$/
那应该可以解决您的问题。
使用[^A-Z]
代替[A-Z]
[^ ]
是相反的。[]
它匹配不包含在括号内的字符
所以,应该是
/^[^A-Z][a-zA-Z]{0,19}$/
或者
只需使用
/^[a-z][a-zA-Z]{0,19}$/