Advertisement
Guest User

Untitled

a guest
Mar 13th, 2012
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6.  
  7. namespace ConsoleApplication3
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string sPattern = @"\bcow\b";
  14. string[] sentences = { "coward", "lol cow heh", "lolcow", "cowlol", "cow lol", "cow" };
  15.  
  16. foreach (string s in sentences)
  17. {
  18. System.Console.Write("{0,24}", s);
  19.  
  20. if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
  21. {
  22. System.Console.WriteLine(" (match for '{0}' found)", sPattern);
  23. }
  24. else
  25. {
  26. System.Console.WriteLine();
  27. }
  28. }
  29.  
  30.  
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement