欢迎来到3672js教程,我们关注js教程、js框架、js代码特效等。

asp email邮箱地址验证正则表达式

3672Js.Com2019-03-10 10:41 来源:未知 阅读:15627 关注度5

asp email邮箱地址验证正则表达式


上篇文章我们用字符串查找的方法实现了asp email邮箱地址的验证,有可能比较喜欢正则表达式的朋友,这里也给出相应的代码。
方法一

复制代码 代码如下:

Public Function ChkMail(ByVal Email)
Dim Rep,Pmail : ChkMail = True : Set Rep = New RegExp
Rep.Pattern = "([.a-zA-Z0-9_-]){2,10}@([a-zA-Z0-9_-]){2,10}(.([a-zA-Z0-9]){2,}){1,4}$"
Pmail = Rep.Test(Email) : Set Rep = Nothing
If Not Pmail Then ChkMail = False
End Function

邮箱地址验证二
复制代码 代码如下:

<%
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
%>

方法三
复制代码 代码如下:

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
%>

我们来看看验证一的实例使用方法
复制代码 代码如下:

If ChkMail(admin@jb51.net) = True Then
Response.Write "格式正确"
Else
Response.Write "格式有误"
End If

本站文章为3672js教程网友分享投稿,版权归原作者,欢迎任何形式的转载,但请务必注明出处。同时文章内容如有侵犯了您的权益,请联系我们处理。
评论已被关闭
{dede:include filename="foot.htm"/}