fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var s = "adj 1: text1 2: text2 n 1: text4 adj 1: text5 adv 1: text6 3: text7";
  9. var block = @"(?:[nv]|ad[vj])?\s*\d+:";
  10. var pat = string.Format(@"{0}.*?\s*(?={0})", block);
  11. Console.Write(Regex.Replace(s, pat, "$&\n"));
  12. }
  13. }
Success #stdin #stdout 0.12s 24728KB
stdin
Standard input is empty
stdout
adj 1: text1 
2: text2 
n 1: text4 
adj 1: text5 
adv 1: text6 
3: text7