2

I want to match any string that does not contain the string "None" in any case (Case Insensitive Match),

I referred the question C# Regex to match a string that doesn't contain a certain string?

The said question gives the solution for a case sensitive, but I need to disallow the string "None" in any Case.

I need a generic regular expression for disallowing the string (Case Insensitive Match).

For Example:

  • NONE
  • None
  • NoNe
  • none
  • nOnE
  • NonE
  • nONe, etc.,

Kindly assist me...

  • @GiladGreen - I'm validating the string with multiple constrains via Regular expression, this is one of the sub-check... –  Jun 30 '17 at 11:11
  • @wiktor - Kindly let me know which one is duplicate out of your two marked questions. Kindly mark any one of the marked question is duplicate. I'm eagerly awaiting. –  Jun 30 '17 at 12:07

1 Answers1

7

Use RegexOptions.IgnoreCase:

Regex.Matches( text, @"^(?!.*None).*$", RegexOptions.IgnoreCase );
Regex.IsMatch( text, @"^(?!.*None).*$" , RegexOptions.IgnoreCase );
Derek
  • 7,615
  • 5
  • 33
  • 58