fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. string pattern = @"\b[fF]iles\b[^*()]*(?:\([^()]*\))?\|\*(?<ext>\.[\w*]+)(?:[,;]\*(?<ext>\.[\w*]+))*";
  11. string input = @"txt files `(*.txt)|*.txt|All files (*.*)|*.*`
  12. Image Files`|*.jpg;*.jpeg;*.png;`
  13. Excel Files `(*.xls, *.xlsx)|*.xls;*.xlsx|CSV Files (*.csv)|*.csv`";
  14.  
  15. var strings = Regex.Matches(input, pattern)
  16.  
  17. .SelectMany(m => m.Groups["ext"].Captures.Select(c => c.Value))
  18. .ToArray()
  19. .Distinct();
  20.  
  21. foreach (var s in strings)
  22. {
  23. Console.WriteLine(s);
  24. }
  25. }
  26. }
Success #stdin #stdout 0.09s 30700KB
stdin
Standard input is empty
stdout
.txt
.*
.jpg
.jpeg
.png
.xls
.xlsx
.csv