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