In php, the preg_match username is a regular instance. For example, the code for letters, numbers, and Chinese characters is as follows: if (preg_match ([.,:;*?~ '! @ # $ % ^ +) ({}] |] | [|, $ User) {echo should not contain special characters in the name, use only letters, numbers, letters, numbers, and Chinese characters
| The code is as follows: |
< td> |
|
If (preg_match ("/['.,:;*?~ '! @ # $ % ^ & + =) (<>{}] | [|/| \ | "|/", $ User )){
Echo 'Do not enclose some special characters in the name. please only use letters, numbers, and Chinese characters. of course, you must select simplified Chinese GB2312 in your browser, do not select traditional Chinese or Chinese HZ. Come back and wait for you! ';
Exit ();
}
|
Example: all letters
| The code is as follows: |
< td> |
|
If (mb_ereg ("^ [w-.] {1, 32} $", $ str )){
Echo 'yes ';
} Else {
Echo 'no http://www.111cn.net /';
}
?> |
Some common regular expressions
The username must start with a number or letter and end with a length of 4 ~ 18 characters
| The code is as follows: |
< td> |
|
The username is an uppercase letter, lowercase letter, or underscore, and starts with a letter. the username must be 6-20 characters long.
| The code is as follows: |
< td> |
|
Username: The username can contain lowercase letters, Chinese characters, numbers, and underscores (_). The username cannot contain only numbers, but cannot contain underscores (_).
| The code is as follows: |
< td> |
| UTF-8Preg_match ("/^ [a-z0-9_x80-xff] + [^ _] $/g", $ );Under gbk:Preg_match ("/^ [a-z0-9 _". chr (0xa1). "-". chr (0xff). "] + [^ _] $/", $)
User name verification in Chinese
| The code is as follows: |
< td> |
|
Articles you may be interested in
- Php username regular expression, including Chinese characters, with a length of 4-16 characters
- Verify the php regular expression of the user name url in the email format
- Php username regular expression (Chinese, English, numbers, letters)
- Regular expression of numbers and letters (user name verification)
- Php regular code for verifying username validity
- Php common regular expression mailbox username password ip html tag
- Preg_match: Regular expression used to determine the user name
- Php regular expression verification username
The signature code is as follows if (preg_match ("/['.,:;*?~ '! @ # $ % ^ + =) ({}] |] | [|/| \ | "|/", $ User )) {echo 'Do not enclose special characters in the name. please use only letters, numbers...