Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7.  
  8. namespace WILDCARD
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Console.WriteLine("Enter a string:");
  15. string inp = Console.ReadLine();
  16.  
  17. Console.WriteLine("Enter a pattern:");
  18. string pat = Console.ReadLine();
  19.  
  20. bool match = Regex.IsMatch(inp, WildCard(pat));
  21. Console.WriteLine(match + ":\n"+inp);
  22.  
  23.  
  24.  
  25. }
  26. private static String WildCard(String value)
  27. {
  28. return "^" + Regex.Escape(value).Replace("\\*", ".*") + "$";
  29. }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement