php教程 用户名正则表达式(中文,英文,数字,字母)
由字母a~z(不区分大小写)、数字0~9、减号或下划线组成
只能以数字或字母开头和结尾 用户名长度为4~18个字符
^[a-za-z0-9]{1}[a-za-z0-9|-|_]{2-16}[a-za-z0-9]{1}$
用户名为大写字母小写字母或下划线,并以字母开头,长度为6-20
^[a-za-z][wd_]{5,19}
用户名:包括英文小写、汉字、数字、下划线,不能全部是数字,下划线不能在末尾
/^[a-z0-9_u4e00-u9fa5]+[^_]$/g
utf-8下
preg_match("/^[a-z0-9_x80-xff]+[^_]$/g",$a);
gbk下:
preg_match("/^[a-z0-9_".chr(0xa1)."-".chr(0xff)."]+[^_]$/",$a)
可有中文的用户名验证
[a-za-z0-9][u4e00-u9fa5]
由于我们写的表达式是匹配一个字符串的任何部分。它将不止认为'mike_84′是合法字符串,同样也会匹配类似'%! mike_84&'这种包含了我们不希望出现的东西的字符串。我们需要用到行定位点, ^ (caret) 和 $ (dollar) 字符将把我们的表达式限制在一个字符串的起点和终点位置,这样可以确保整个用户名符合我们的设定,而不是一部分。
所以修订版的正则表达式象这样:
/^[a-za-z0-9_]{3,16}$/

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
