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@haodaima.com) = True Then
Response.Write "格式正确"
Else
Response.Write "格式有误"
End If

以上就是asp email邮箱地址验证正则表达式。有志者,事竞成,破釜沉舟百二秦关终归楚;苦心人,天不负,卧薪尝胆三千越甲可吞吴。更多关于asp email邮箱地址验证正则表达式请关注haodaima.com其它相关文章!

您可能有感兴趣的文章
浅析golang 正则表达式

基于xpath选择器、PyQuery、正则表达式的格式清理工具详解

javascript正则表达式 限1-2位整数,或者至多含有两位小数的写法

正则表达式中的 .*? 或 .*+ 的意思

javascript正则表达式标记中/g /i /m的用法,以及实例