Sylloge
A C# helper library
code/Extensions/Search.cs
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 using System;
00017 using System.Collections.Generic;
00018 using System.Text;
00019 
00020 namespace Sylloge
00021 {
00025     public static class Search
00026     {
00034         public static bool IsWildCardMatch(string searchString, string data, bool ignoreCase)
00035         {
00036             string RegExPattern = "^" + System.Text.RegularExpressions.Regex.Escape(searchString).Replace("\\*", ".*").Replace("\\?", ".") + "$";
00037             System.Text.RegularExpressions.RegexOptions Options = System.Text.RegularExpressions.RegexOptions.None;
00038             if (ignoreCase) { Options = System.Text.RegularExpressions.RegexOptions.IgnoreCase; }
00039             System.Text.RegularExpressions.Regex Regex = new System.Text.RegularExpressions.Regex(RegExPattern, Options);
00040             return Regex.IsMatch(data);
00041         }
00042     }
00043 }
 All Classes Namespaces Files Functions Variables Enumerations Properties Events