Matching multiple strings in RegExp
Posted on 2004-08-19
I want to use VB rebexp regular expressions object to match multiple strings with different structure. e.g. In "37g" I want to match "37" as one string and "g". I tried:
objRE.Pattern = "([0-9]+)([a-z]+)"
objRE.Global = True
Set objMatches = objRE.Execute(SizeString)
but objMatches.count always comes back as 1 and the match is "37g"
I thought that by using two sets of brackets I should get two matches in the objMatches collection (that's what it implies on MSDN: "Matches pattern and remembers the match. The matched substring can be retrieved from the resulting Matches collection, using Item ...[n]. To match parentheses characters ( ), use "\(" or "\)".")