function isUserID($username) {
if (preg_match('/^[a-z\d_]{2,20}$/i', $username)) {
return true;
} else {
return false;
}
}
简单的..,我有这个,你能解释一下它检查什么吗?我知道它会检查用户名的长度是否在 2-20 之间,还有什么?谢谢
它搜索仅包含字母数字和下划线字符、长度为 2 到 20 个字符的文本。
/^[a-z\d_]{2,20}$/i
|||| | ||| |||
|||| | ||| ||i : case insensitive
|||| | ||| |/ : end of regex
|||| | ||| $ : end of text
|||| | ||{2,20} : repeated 2 to 20 times
|||| | |] : end character group
|||| | _ : underscore
|||| \d : any digit
|||a-z: 'a' through 'z'
||[ : start character group
|^ : beginning of text
/ : regex start
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)