找回密码
 立即注册
查看: 844|回复: 0

email正则表达式函数

[复制链接]

148

回帖

1687

基友

1073

积分

通神3段 Lv.6

Rank: 3Rank: 3

发表于 2013-7-22 21:18:45 | 显示全部楼层 |阅读模式
email正则表达式函数,是用来判断EMAIL是否正确,从而更好的给用户发邮件,通知等情况
Function IsValidEmail(email)
Dim names, Name, i, c
IsValidEmail = true
names = Split(email, "@")
If UBound(names) <> 1 Then
  IsValidEmail = false
  Exit Function
End If
For Each Name in names
  If Len(Name) <= 0 Then
   IsValidEmail = false
   Exit Function
  End If
  For i = 1 To Len(Name)
   c = LCase(Mid(Name, i, 1))
   If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then
    IsValidEmail = false
    Exit Function
   End If
  Next
  If Left(Name, 1) = "." Or Right(Name, 1) = "." Then
   IsValidEmail = false
   Exit Function
  End If
Next
If InStr(names(1), ".") <= 0 Then
  IsValidEmail = false
  Exit Function
End If
i = Len(names(1)) - InStrRev(names(1), ".")
If i <> 2 And i <> 3 Then
  IsValidEmail = false
  Exit Function
End If
If InStr(email, "..") > 0 Then
  IsValidEmail = false
End If
End Function
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|苍海国际 ( 鲁ICP备13020644号-1 )

GMT+8, 2024-11-22 07:07 , Processed in 0.034818 second(s), 23 queries .

Powered by Discuz! Theme By eRic Modified by 4bpa

© CangHai International We Do Our Rights!

返回顶部