Learn how to use regular expressions in ASP through several practical examples

Source: Internet
Author: User

?

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

Related Article

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.