fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var s = "<td class='additional-attribute'>1</td><td class='additional-attribute'>2</td><td class='additional-attribute'>3</td>";
  12. var result = Regex.Matches(s, "(?si)<td class=.additional-attribute.>(.*?)<")
  13. .Cast<Match>()
  14. .Take(2) // Взять первые два
  15. .Select(x => x.Groups[1].Value)
  16. .ToList();
  17. foreach (var n in result)
  18. Console.WriteLine(n);
  19. }
  20. }
Success #stdin #stdout 0.03s 134592KB
stdin
Standard input is empty
stdout
1
2