我需要确认域扩展名是否存在。
到目前为止,我无法获得域名扩展名
的匹配域名可以包含通配符:gmail.com,msn.com,mac.com,comcast.net
DomainPartOfEmail = Right(temp, (Len(temp) - temp.LastIndexOf("@") - 1))
If Regex.IsMatch(DomainPartOfEmail, "*.edu? | *.com? | *.net? | *.org?", RegexOptions.IgnoreCase) Then
ValidDomain = True
End If
答案 0 :(得分:1)
如果域名仅来自这些域名(edu,com,net,org),请使用此域名:
".*\.(edu|com|net|org)$"
正则表达式的解释:
NODE EXPLANATION
--------------------------------------------------------------------------------
.* any character except \n (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
\. '.'
--------------------------------------------------------------------------------
( group and capture to \1:
--------------------------------------------------------------------------------
edu 'edu'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
com 'com'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
net 'net'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
org 'org'
--------------------------------------------------------------------------------
) end of \1
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
string