fork(3) download
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var filter = "[quick*jumps*lazy dog]";
  10. var parts = filter.Split('*').Select(s => Regex.Escape(s)).ToArray();
  11. var regex = string.Join(".*?", parts);
  12. Console.WriteLine(regex);
  13. string str;
  14. while ((str = Console.ReadLine()) != null) {
  15. var res = Regex.IsMatch(str, regex);
  16. Console.WriteLine("{0} : {1}", res, str);
  17. }
  18. }
  19. }
Success #stdin #stdout 0.1s 24664KB
stdin
[quick brown fox jumps over the lazy dog]
quick brown fox jumps over the lazy dog
[slow brown fox jumps over the lazy dog]
[quick something jumps with a lazy dog]
stdout
\[quick.*?jumps.*?lazy\ dog]
True : [quick brown fox jumps over the lazy dog]
False : quick brown fox jumps over the lazy dog
False : [slow brown fox jumps over the lazy dog]
True : [quick something jumps with a lazy dog]