【问题标题】:Regex Positive Lookbehind Issue with Excel VBAExcel VBA 的正则表达式正面后向问题
【发布时间】:2015-03-29 08:50:04
【问题描述】:

我正在运行 VBA (Excel 2003) 并测试积极的后向正则表达式模式。我运行下面的函数,但得到以下错误:

Run-time error '5017': Method 'Execute' of object 'IRegExp2' failed

我也试过 Set re = CreateObject("vbscrip.regexp")
但我得到同样的错误。我已经成功地测试了一些积极的前瞻,他们工作。只是后面有问题。我已经用 Expresso 测试了下面的模式,它运行良好。这是 VBA 特有的风味问题吗?

Function regexSearch(pattern As String, source As String) As String
Dim re As RegExp
Dim matches As MatchCollection
Dim match As match
'Create RegEx object
pattern = "(?<=a)b"
source = "cab"
Set re = New RegExp
   re.Multiline = False 
   re.Global = True
   re.IgnoreCase = False
   re.pattern = pattern
'Execute
Set matches = re.Execute(source)
'Output
For Each match In matches
   str = str & match & " "
Next match
regexSearch = str
End Function

【问题讨论】:

  • 您有没有找到解决方法?我不知道还有什么方法可以完成这项工作。

标签: regex excel vba


【解决方案1】:

这是(因此是)所特有的。

不支持后视(负或正)

【讨论】:

  • 谢谢,我就是这么怀疑的。
猜你喜欢
  • 1970-01-01
  • 2012-01-14
  • 2016-01-13
  • 2018-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多