How to return the second value of the regular expression (C#)?

Hello. There is the regular season
var find1 = Regex.Match(s,"<td class=.additional-attribute.>(.*?)<", RegexOptions.Singleline | RegexOptions.IgnoreCase).Groups[1].Value;


This expression corresponds to 5 results.
I need to get the first 2.

It doesn't help :(
var find1 = Regex.Match(s,"<td class=.additional-attribute.>(.*?)<", RegexOptions.Singleline | RegexOptions.IgnoreCase).Groups[2].Value;


(Groups[1] changed to Groups[2])

Help :)
March 20th 20 at 11:49
1 answer
March 20th 20 at 11:51
possible infinite loop: matches[pos].Groups[1].ToString();
Add-Type -IgnoreWarnings -TypeDefinition @'
using System;
using System.Text;
using System.Text.RegularExpressions;
public class Test {
public string findMatches(string text, int pos) {
MatchCollection matches = Regex.Matches(text,@"([a-z]+)", RegexOptions.Singleline | RegexOptions.IgnoreCase);
Console.Error.WriteLine(matches.Count);
Console.Error.WriteLine(matches[pos].Groups.Count);

 return matches[pos].Groups[1].ToString();
}
}
'@
$o = new-object -TypeName 'Test'
write-output ('=> "{0}"' -f $o.findMatches("a b c d", 3))

Find more questions by tags Regular expressionsC#