好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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

查看更多关于asp email邮箱地址验证正则表达式_正则表达式的详细内容...

  阅读:53次