fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.IO;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var s = "This is a {test} %String%. %Stack% {Overflow}";
  9. var regex = "(?:(?<p>%)|(?<b>{))(?<v>.*?)(?(p)%|})";
  10. var matches = Regex.Matches(s, regex, RegexOptions.Singleline);
  11. foreach (Match match in matches)
  12. {
  13. Console.WriteLine(match.Groups["v"].Value);
  14. }
  15. }
  16. }
Success #stdin #stdout 0.11s 24712KB
stdin
Standard input is empty
stdout
test
String
Stack
Overflow