Example: letters, numbers, and Chinese characters
The Code is as follows: |
|
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: |
|
<? Php 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 username is an uppercase letter, lowercase letter, or underscore, and starts with a letter. The username must be 6-20 characters long.
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: |
|
| 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
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