I need to loop through all the matches in say the following string:
<a href='/Product/Show/{ProductRowID}'>{ProductName}</a>
I am looking to capture the values in the {} including them, so I want {ProductRowID} and {ProductName}
Here is my code so far:
Dim r As Regex = New Regex('{\w*}', RegexOptions.IgnoreCase) Dim m As Match = r.Match('<a href='/Product/Show/{ProductRowID}'>{ProductName}</a>')
Is my RegEx pattern correct? How do I loop through the matched values? I feel like this should be super easy but I have been stumped on this this morning!
Your Pattern is missing a small detail:
Curly braces must be escaped, and you want the non-greedy star, or your first (and only) match will be this:
'{ProductRowID}'>{ProductName}'.RegexOptions.IgnoreCaseis not needed, because this particular regex is not case sensitive anyway.