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...

2
  • @GiladGreen - I'm validating the string with multiple constrains via Regular expression, this is one of the sub-check... Commented Jun 30, 2017 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. Commented Jun 30, 2017 at 12:07

1 Answer 1

8

Use RegexOptions.IgnoreCase:

Regex.Matches( text, @"^(?!.*None).*$", RegexOptions.IgnoreCase );
Regex.IsMatch( text, @"^(?!.*None).*$" , RegexOptions.IgnoreCase );
Sign up to request clarification or add additional context in comments.

Comments