Grabbing all regex matches of "$#" from a string
I have a string that contains multiple instances of a dollar sign followed by a positive number. I need to grab each instance out using regex.
Here's an example of a string:
"This that $1 who $2"
Here's what I have so far using vb.net:
Dim wordSplitMatches As Match = Regex.Match("This that $1 who $2", "(\$\d+)+")
This works great for grabbing the $1 but how d开发者_开发问答o I set it up so that I get multiple groups with all the matches in?
This is the output at the moment:
? wordsplitmatches.groups(1).value
"$1"
? wordsplitmatches.groups(2).value
""
Regex.Match only returns the first match.
Use Regex.Matches to return all matches.
精彩评论