/// <summary>
/// 是否匹配正则表达式
/// </summary>
/// <param name="input">输入的字符串</param>
/// <param name="pattern">正则表达式</param>
/// <param name="ignoreCase">是否忽略大小写</param>
/// <returns></returns>
[Microsoft.SqlServer.Server.SqlFunction]
public static bool RegexMatch(string input, string pattern, bool ignoreCase)
{
bool isMatch = false;
if (!string.IsNullOrEmpty(input) && !string.IsNullOrEmpty(pattern))
{
try
{
Match match = null;
if (ignoreCase)
match = Regex.Match(input, pattern, RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.Compiled);
else
match = Regex.Match(input, pattern, RegexOptions.Multiline | RegexOptions.Compiled);
if (match.Success)
isMatch = true;
}
catch { }
}
return isMatch;
}