2

私が現在持っている正規表現のコードは、大文字と小文字が完全に一致するものを探すので、大文字と小文字を無視するにはどのような変更を加える必要がありますか?

public static bool ExactMatch(string input, string match)
{
    return Regex.IsMatch(input, string.Format(@"\b{0}\b", Regex.Escape(match)));
}
4

5 に答える 5

6

これはうまくいくはずです:

public static bool ExactMatch(string input, string match)
{
    return Regex.IsMatch(input, string.Format(@"\b{0}\b", Regex.Escape(match)), RegexOptions.IgnoreCase);
}
于 2013-05-22T15:20:01.760 に答える
0

RegexOption.IgnoreCaseはオプションである必要があります..

Regex.IsMatch(input, string.Format(@"\b{0}\b", Regex.Escape(match)), RegexOptions.IgnoreCase)
于 2013-05-22T15:23:16.057 に答える