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.