请问VB正则表达式怎么取子表达式的值?

来源:百度知道 编辑:UC知道 时间:2024/05/24 02:29:27
VB6正则表达式,怎么取子字表达式匹配(括号中的表达式)的值。
如正则表达式"\s\(d+)\s"中(d+)匹配的值如何取出。
求代码。
或者给个VB中Microsoft VBScript Regular Expressions 5.5完全使用手册

Dim str As String
Dim reg As Object
Dim match As Object

str = " 123 "

Set reg = CreateObject("VBScript.RegExp")
reg.Global = True
reg.Pattern = "\s(\d+)\s"

For Each match In reg.Execute(str)
' MsgBox match.Value
MsgBox "子匹配:" & match.SubMatches(0)
' MsgBox match.FirstIndex
' MsgBox match.Length
Next
Set reg = Nothing