Regular Expression for ASP email address verification

Source: Internet
Author: User

Part 1ArticleWe use the string SEARCH method to verify the ASP email address. It may be a friend who prefers regular expressions.Code.
Method 1

Copy code The 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 Code the code is as follows: if chkmail (admin@jb51.net) = true then
response. write "The format is correct"
else
response. write "Incorrect format"
end if

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.