Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace ConsoleApplication3
- {
- class Program
- {
- static void Main(string[] args)
- {
- string sPattern = @"\bcow\b";
- string[] sentences = { "coward", "lol cow heh", "lolcow", "cowlol", "cow lol", "cow" };
- foreach (string s in sentences)
- {
- System.Console.Write("{0,24}", s);
- if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
- {
- System.Console.WriteLine(" (match for '{0}' found)", sPattern);
- }
- else
- {
- System.Console.WriteLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement