如何使用vba格式化许多使用正则表达式的电子邮件

问题描述 投票:0回答:1

使用vba,我希望用分号验证之间的许多电子邮件,每封邮件必须以@cicomercurrency.com结尾,用户可以根据需要输入2或3或4封或许多电子邮件。示例:[email protected]; [email protected]; [email protected]我的代码在这里。但它可能有问题。

Public Function ValidateEmailAddressWithSemi(ByRef strEmailAddress As String) As Boolean
    'Create Regular expression object
    Dim objRegExp As New RegExp

    'Set Case insensitive
    objRegExp.IgnoreCase = True
     objRegExp.pattern = "^\s?([_a-z0-9-]+(.[a-z0-9-]+)@customconcurrency.com)+([;.]([_a-z0-9-]+(.[a-z0-9-]+)@customconcurrency.com)*$"
    ValidateEmailAddress = objRegExp.Test(strEmailAddress)

End Function
excel vba
1个回答
0
投票

尝试这种模式:

"^\s?([_a-z0-9-]+(.[a-z0-9-]+)@customercurrency.com)+([;.]([_a-z0-9-]+(.[a-z0-9-]+)@customercurrency.com))*$"

(缺少域名和括号内)

© www.soinside.com 2019 - 2024. All rights reserved.