C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Note: When IgnoreCase is specified, the match succeeds. Otherwise it fails. IgnoreCase will relax the regular expression.
C# program that uses RegexOptions.IgnoreCase
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
// The input string has an uppercase trailing letter.
const string value = "carroT";
// Print result of IsMatch method:
// ... With IgnoreCase;
// ... And without any options set.
Console.WriteLine(Regex.IsMatch(value, "carrot", RegexOptions.IgnoreCase));
Console.WriteLine(Regex.IsMatch(value, "carrot"));
}
}
Output
True
False
Tip: The RegexOptions.IgnoreCase argument is useful in many regular expressions.