Take the 2-minute tour ×

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 do 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
? wordsplitmatches.groups(2).value
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Regex.Match only returns the first match.

Use Regex.Matches to return all matches.

share|improve this answer
Knew it would be simple. Thanks alot. –  ChrisO Jun 24 '11 at 0:58
add comment

Your Answer


