Regular expression to validate user name

Source: Internet
Author: User
Tags expression regular expression

To find a regular expression that validates a user name
Dear eldest sister, the younger generation to seek a verification of the user name of the regular expression, hard thinking for one weeks or did not get out, I am dull, also hope everyone advice!
VBScript programming requires that the characters of the username be controlled between 3 and 20, made up of Chinese, uppercase and lowercase letters, numbers, underscores, decimal points, and minus signs, the combination of one of the three characters that must end with an underscore, decimal point, or minus sign in English or a number cannot be consecutive a__a or a--a or a .. A such, but can a_a.a_a.a_a-a-a-a_a-a.a.a.a such.
If this range is exceeded, the user name does not pass.
I just can't figure it out. The combination of one of the three characters, the underscore, the decimal point, the minus sign, the head is big.
This is a non conformance regular:
^. {0,2}$|. {21,}|^[^a-za-z0-9u4e00-u9fa5]| [^wu4e00-u9fa5.-]| ([_.-]) 1

<script language=vbscript>

function Regtest (str)

Set re = New RegExp

Re. Pattern = "^. {0,2}$|. {21,}|^[^a-za-z0-9u4e00-u9fa5]| [^wu4e00-u9fa5.-]| ([_.-]) 1 "

if re. Test (str) Then

MsgBox ("Not conforming")


MsgBox ("compliant")

End If

End Function


<input id=strs value= "A_a.a_a.a_a-a-a_a-a" size=40>

<input Type=button onclick=regtest (strs.value) value= "Check" >

(?! Pattern
A negative check matches the lookup string at the beginning of any mismatched negative lookahead matches the search string at either point where a string is not matching. This is a non-fetch match, that is, the match does not need to be acquired for later use. For example, ' Windows (?! 95|98| nt|2000) ' Can match windows in Windows 3.1, but cannot match windows in Windows 2000. It does not consume characters, that is, after a match occurs, the next matching search begins immediately after the last match, instead of starting after the character that contains the pre-check.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.