PHP Tutorial User name Regular expression (Chinese, English, digit, letter)
Consists of a letter a~z (case-insensitive), a numeric 0~9, a minus sign, or an underscore
You can only start and end a number or letter with a 4~18 character length
^[a-za-z0-9]{1}[a-za-z0-9|-|_]{2-16}[a-za-z0-9]{1}$
The user name is uppercase or lowercase letters or underscores and begins with a letter with a length of 6-20
^[A-ZA-Z][WD_]{5,19}
User name: including English lowercase, Chinese characters, numbers, underscores, cannot be all numbers, underline cannot be at the end
/^[a-z0-9_u4e00-u9fa5]+[^_]$/g
Utf-8 under
Preg_match ("/^[a-z0-9_x80-xff]+[^_]$/g", $a);
GBK under:
Preg_match ("/^[a-z0-9_". Chr (0XA1). " -". Chr (0xFF)."] +[^_]$/", $a)
Can have Chinese user name verification
[A-za-z0-9] [U4e00-u9fa5]
Because we write an expression that matches any part of a string. It will not only think ' mike_84′ is a legitimate string, it will also match similar '%! mike_84& ' This string that contains something we don't want to appear in. We need to use line anchors, ^ (caret) and $ (dollar) characters will limit our expression to the start and end of a string to ensure that the entire username fits our set, not part of it.
So the regular expression of the revised version looks like this:
/^[a-za-z0-9_]{3,16}$/