Regular Expression – How to find a match within a match?

Use the expression “<(\d+)>”

You can then access all matches as a collection. Your regex can match more than once if you set RegEx.Global = True. The first match is found in var(0), second at var(1). Submatch groups are found at var(0).SubMatches(0), etc. If you’re only doing it once, you can one line it:

Dim RegEx : Set RegEx = New RegExp
RegEx.Pattern = "<(\d+)>"
Dim strTemp : strTemp = "12<56>89"
WScript.Echo RegEx.Execute(strTemp)(0).SubMatches(0)

Test out your regular expressions here:
http://www.regular-expressions.info/vbscriptexample.html

Leave a Comment