subexpressions.vbs

来自「Apress - Managing Enterprise Systems Wit」· VBS 代码 · 共 14 行

VBS
14
字号
Dim objRegExp, objMatches, objSubMatches
'Set objRegExp = New RegExp
Set objRegExp = CreateObject("VBScript.RegExp")
' match "digits slash digits slash digits"
objRegExp.Pattern = "(\d+)\/(\d+)\/(\d+)"
Set objMatches = objRegExp.Execute("5/13/2000")
'the first element of the matches collection contains the submatches
Set objSubMatches = objMatches(0).SubMatches
'list the number of sub expression matches and matches
Wscript.Echo "Subexpression count " & objSubMatches.Count
Wscript.Echo "Subexpression 1 " & objSubMatches (0)
Wscript.Echo "Subexpression 2 " & objSubMatches (1)
Wscript.Echo "Subexpression 3 " & objSubMatches (2)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?