fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var strs = new List<string> {"this is a test for <<bob>> who like <<books>>",
  10. "test 2 <<frank>> likes nothing",
  11. "test 3 <<what>> <<on>> <<earth>> <<this>> <<is>> <<too>> <<much>>." };
  12. foreach (var s in strs)
  13. {
  14. var results = Regex.Matches(s, @"<<(.*?)>>", RegexOptions.Singleline)
  15. .Cast<Match>()
  16. .Select(x => x.Groups[1].Value);
  17. Console.WriteLine(string.Join(", ", results));
  18. }
  19.  
  20. }
  21. }
Success #stdin #stdout 0.03s 134592KB
stdin
Standard input is empty
stdout
bob, books
frank
what, on, earth, this, is, too, much