Created
May 23, 2011 22:19
-
-
Save palfrey/987752 to your computer and use it in GitHub Desktop.
StringLike C# function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Text.RegularExpressions; | |
| public static class StringExtensions | |
| { | |
| [System.Data.Objects.DataClasses.EdmFunction("Your.Namespace", "StringLike")] | |
| public static Boolean StringLike(this String searchingIn, String lookingFor) | |
| { | |
| if (searchingIn == null) | |
| return false; | |
| Regex r = new Regex(lookingFor.ToLower().Replace("%", @"[\w\s]*")); | |
| return r.IsMatch(searchingIn.ToLower()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment