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 text = "<span class=\"kanji-1-up kanji\">ま</span><span class=\"kanji-2-up kanji\">ちが</span><span></span>";
  12. var textArray = Regex.Matches(text, @"(?s)<span(?:\s+[^>]*)?>(.*?)</span>")
  13. .Cast<Match>()
  14. .Select(x => x.Groups[1].Value);
  15. foreach (var item in textArray)
  16. Console.WriteLine($"'{item}'");
  17. }
  18. }
Success #stdin #stdout 0.07s 22036KB
stdin
Standard input is empty
stdout
'ま'
'ちが'
''