如何在vb6中使用正则表达式提取文本
Dim MyText As String
MyText = "anything [*]textToExtract[*] anything"
结果应该是:
textToExtract
答案 0 :(得分:3)
Sub test()
Dim re As RegExp, m As MatchCollection
Set re = New RegExp
Dim MyText As String, extractedText As String
MyText = "anything textToExtract anything"
re.Pattern = "anything (.*) anything"
Set m = re.Execute(MyText)
extractedText = m(0).SubMatches(0)
End Sub