Skip to content

Instantly share code, notes, and snippets.

@palfrey
Created May 23, 2011 22:19
Show Gist options
  • Select an option

  • Save palfrey/987752 to your computer and use it in GitHub Desktop.

Select an option

Save palfrey/987752 to your computer and use it in GitHub Desktop.
StringLike C# function
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