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 line = "ID is PK_myid some more words\nID is PK_ my id some more words";
  12. var pattern = @"\bID\s+is\s+(\w+(?:\s+\w+)*?)\s+some\b";
  13. var output = Regex.Matches(line, pattern)
  14. .Cast<Match>()
  15. .Select(x => x.Groups[1].Value);
  16. foreach (var s in output)
  17. Console.WriteLine(s);
  18. }
  19. }
Success #stdin #stdout 0.06s 30804KB
stdin
Standard input is empty
stdout
PK_myid
PK_ my id