How to compare two string with IgnoreCase using Regex() in C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            string s = "c# PROG";

            Console.WriteLine(Regex.IsMatch(s, "c# prog", RegexOptions.IgnoreCase));
            Console.WriteLine(Regex.IsMatch(s, "c# prog"));
            Console.WriteLine(Regex.IsMatch(s, "c# Prog"));
        }
    }
}


/*
run:
  
True
False
False

*/

 



answered Feb 8, 2017 by avibootz

Related questions

1 answer 180 views
1 answer 183 views
1 answer 191 views
1 answer 192 views
1 answer 176 views
...