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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2021-03-18 我要评论
想了解asp email邮箱地址验证正则表达式的相关内容吗,在本文为您仔细讲解asp email 邮箱验证的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们