【发布时间】:2016-10-21 11:28:49
【问题描述】:
我正在尝试从一系列电子邮件中提取文本。这些邮件看起来像:
你好,
bla bla bla。原因是:问题解决后 全部
亲切的问候,
呜呜呜
我有一个像这样的正则表达式:
With ReasonReg
.Pattern = "(The reason for this is\s*:\s*)(\w\s*)+(?=\s*Kind regards)"
.Global = False
.IgnoreCase = False
End With
我的问题出现在使用数字和特殊字符(冒号和问号)的邮件上。当然,\w 与这些不匹配,但如果我尝试以下任何操作,我的 Outlook (Office 365) 将变得无响应。
.Pattern = "(The reason for this is\s*:\s*)(.*\s*)+(?=\s*Kind regards)"
.Pattern = "(The reason for this is\s*:\s*)(\w\W*\s*)+(?=\s*Kind regards)"
.Pattern = "(The reason for this is\s*:\s*)(\w[:?]*\s*)+(?=\s*Kind regards)"
【问题讨论】:
-
试试
.Pattern = "(The reason for this is\s*:\s*)([\s\S]*?)(\s*Kind regards)"
标签: regex vba email outlook special-characters