C# Wildcard match

Date: 2019-10-28
// using System.Text.RegularExpressions;
public static bool WildcardMatch(string pattern, string aString)
{
	Regex regex = new Regex(WildcardToRegex(pattern), RegexOptions.IgnoreCase);
	return regex.IsMatch(aString);
}

public static string WildcardToRegex(string pattern)
{
	return "^" + Regex.Escape(pattern).
	Replace("\\*", ".*").
	Replace("\\?", ".") + "$";
}
27490cookie-checkC# Wildcard match