preg_match()和用户名

Kar*_*rem 8 php regex preg-match

function isUserID($username) {
  if (preg_match('/^[a-z\d_]{2,20}$/i', $username)) {
    return true;
  } else {
    return false;
  }
}   
Run Code Online (Sandbox Code Playgroud)

简单的...,我有这个,你能解释它检查的内容吗?我知道它会检查用户名是否有2到20之间的长度,还有什么?谢谢

Dag*_*bit 30

它搜索仅包含字母数字和下划线字符的文本,长度为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