Check for case insensitive match for the word BAR1 to BAR99
i.e. possible list of matches in this range are:
BAR1, bar1, BAR2,BAR3,BAR10,...BAR99,BaR99
i.e. possible list of matches in this range are:
BAR1, bar1, BAR2,BAR3,BAR10,...BAR99,BaR99
static void IsMatchFound()
{
string pattern = @"^BAR([1-99]{1,2}|10|20|30|40|50|60|70|80|90)$";
Console.WriteLine("Enter input:");
string input = Console.ReadLine();
if (input == "C")
{
Console.Clear();
}
Match result = Regex.Match(input, pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
if (result.Success)
{
Console.WriteLine("Valid");
}
else
{
Console.WriteLine("Invalid");
}
}
0 comments:
Post a Comment