If you just want to check if a match exists, use IsMatch:
using System;
using System.Text.RegularExpressions;
class Program
{
public static void Main()
{
string s = "Net Amount";
bool isMatch = Regex.IsMatch(s, @"Net\s*Amount",
RegexOptions.IgnoreCase);
Console.WriteLine("isMatch: {0}", isMatch);
}
}
Update: In your comments it sounds like the string you want to search for is only known at runtime. You could try building the regular expression dynamically, for example something like this:
using System;
using System.Text.RegularExpressions;
class Program
{
public static void Main()
{
string input = "Net Amount";
string needle = "Net Amount";
string regex = Regex.Escape(needle).Replace(@"\ ", @"\s*");
bool isMatch = Regex.IsMatch(input, regex, RegexOptions.IgnoreCase);
Console.WriteLine("isMatch: {0}", isMatch);
}
}