我目前拥有的正则表达式代码将寻找与大小写完全匹配的代码,那么我必须进行哪些更改才能忽略大小写?
public static bool ExactMatch(string input, string match)
{
return Regex.IsMatch(input, string.Format(@"\b{0}\b", Regex.Escape(match)));
}
最佳答案
这应该有效:
public static bool ExactMatch(string input, string match)
{
return Regex.IsMatch(input, string.Format(@"\b{0}\b", Regex.Escape(match)), RegexOptions.IgnoreCase);
}
关于C# 正则表达式匹配一行中的精确字符串但忽略大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16695560/