[英]Regex: Password validation of php
I'm working on some password validation on my new project. 我正在为我的新项目进行一些密码验证。 I have this rules that i want to convert on regex pattern using php preg_match() function:
我有这个规则,我想使用php preg_match()函数转换正则表达式模式:
Thanks you in advance! 提前谢谢你!
Try this 尝试这个
(?s)^(\S{4,20})$
Explanation 说明
"(?s)" + // Match the remainder of the regex with the options: dot matches newline (s)
"^" + // Assert position at the beginning of the string
"(" + // Match the regular expression below and capture its match into backreference number 1
"\\S" + // Match a single character that is a “non-whitespace character”
"{4,20}" + // Between 4 and 20 times, as many times as possible, giving back as needed (greedy)
")" +
"$" // Assert position at the end of the string (or before the line break at the end of the string, if any)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.