Regular expression to validate user name

Source: Internet
Author: User
Tags 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")

Else

MsgBox ("compliant")

End If

End Function

</script>

<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.

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.