Regular Expression for asp email address verification

Source: Internet
Author: User

In the previous article, we used the string SEARCH method to verify the asp email address. Some friends may prefer regular expressions. The corresponding code is also provided here.
Method 1
Copy codeThe Code is as follows:
Public Function ChkMail (ByVal Email)
Dim Rep, Pmail: ChkMail = True: Set Rep = New RegExp
Rep. pattern = "([. a-zA-Z0-9 _-]) {} @ ([a-zA-Z0-9 }(. ([a-zA-Z0-9]) {2,}) {} $"
Pmail = Rep. Test (Email): Set Rep = Nothing
If Not Pmail Then ChkMail = False
End Function

Email address verification 2
Copy codeThe Code is as follows:
<%
Function isemail (strng)
Isemail = false
Dim regEx, Match
Set regEx = New RegExp
RegEx. pattern = "^ w + (-w +) | (. w +) * @ [A-Za-z0-9] + ((. |-) [A-Za-z0-9] + )*. [A-Za-z0-9] + $"
RegEx. IgnoreCase = True
Set Match = regEx. Execute (strng)
If match. count then isemail = true
End Function
%>

Method 3
Copy codeThe Code is as follows:
Public Function IsEmail (ByVal PString)
Dim Plt, Pgt: Plt = False: Pgt = False
For x = 2 To Len (PString)-1
If Mid (PString, x, 1) = "@" Then Plt = True
If Mid (PString, x, 1) = "." And Plt = True Then Pgt = True
Next
If Plt = True And Pgt = True Then
IsEmail = True
Else
IsEmail = False
End if
End Function
%>

Let's take a look at how to verify the use of instance 1.
Copy codeThe Code is as follows:
If ChkMail (admin@jb51.net) = True Then
Response. Write "The format is correct"
Else
Response. Write "Incorrect format"
End If

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.