fork(5) download
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var matches = Regex.Matches("Test {Token1} {Token 2}", @"{([^{}]*)");
  9. var results = matches.Cast<Match>().Select(m => m.Groups[1].Value).Distinct().ToList();
  10. Console.WriteLine(String.Join(", ", results));
  11. matches = Regex.Matches("Test {Token1} {Token {2}}", @"{((?>[^{}]+|{(?<c>)|}(?<-c>))*(?(c)(?!)))");
  12. results = matches.Cast<Match>().Select(m => m.Groups[1].Value).Distinct().ToList();
  13. Console.WriteLine(String.Join(", ", results));
  14. }
  15. }
Success #stdin #stdout 0.13s 24488KB
stdin
Standard input is empty
stdout
Token1, Token 2
Token1, Token {2}