[英]I am looking to write a regular expression to allow 6 characters and within the 6 characters, It should only allow 3 alphabets and 3 numbers
我希望编写一个正则表达式以允许 6 个字符,并且在 6 个字符内,它应该只允许 3 个字母和 3 个数字。
Its like a password validation:它就像密码验证:
^(?=(?:.*[a-zA-Z]){3})(?=(?:.*[0-9]){3})[a-zA-Z0-9]{6}$
Anchor the begin and end of string forces 6 characters only.锚定字符串的开头和结尾仅强制 6 个字符。
^
# Must have 3 letters
(?=
(?: .* [a-zA-Z] ){3}
)
# Must have 3 numbers
(?=
(?: .* [0-9] ){3}
)
# Must have 6 characters
[a-zA-Z0-9]{6}
$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.