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. string input = @"{b sub}{b or}{b di}{b nate} def1...
  12. {b sub}{b tro}{b pi}{b cal} def2...
  13. {b su}{b per} def3...
  14. {b sum} def4... ";
  15. string result = Regex.Replace(input, @"(?:\{b\s+[^{}]*})+", m =>
  16. "'" + Regex.Replace(m.Value, @"\{b\s+([^{}]*)}", "$1") + "':");
  17. Console.WriteLine(result);
  18. }
  19. }
Success #stdin #stdout 0.04s 134592KB
stdin
Standard input is empty
stdout
'subordinate': def1...
'subtropical': def2...
'super': def3...
'sum': def4...