?
Learn how to use regular expressions in ASP through several practical examples
We know that regular expressions are supported in VBScript 5.0. Below we use several common application examples to help us
Understand and use thisProgramWriting format
1 first, password verification our password verification rules are: the first letter of the password cannot be a number, the password length is between 4 and 16
The password can contain only characters, numbers, and underscores.
Let's not consider whether this restriction makes sense. Our task is to learn regular expressions.
Function validatepassword (strpassword)
Dim re
Set Re = new Regexp
Re. ignorecase = false
Re. Global = false
Re. pattern = "^ [A-Za-Z]/W {3, 15} $"
Validatepassword = Re. Test (strpassword)
End Function
Explanations
^ Indicates that the rules connected to the backend are the processing limit for the first character, which must be determined by [a-Za-Z ].
The rule for [a-Za-Z] is -- "[" indicates starting from "]" indicates ending.
{And} indicates not including (and) indicates contain
The expression rules for characters, numbers, and underscores are/W.
According to this rule, we will continue to look at a verification rule for the email address.
2. Email address verification
The email check rules are generally used for the mail address detection rules.
Through these two examples, we can briefly understand the powerful functions of Regular Expressions in practical applications .?