我想匹配任何不包含字符串“None”的字符串(不区分大小写的匹配),
我提到了这个问题 C# Regex to match a string that doesn't contain a certain string?
上述问题给出了区分大小写的解决方案,但我需要禁止使用字符串 无论如何,“无”。
我需要一个通用正则表达式来禁止字符串(不区分大小写的匹配)。
例如:
使用RegexOptions.IgnoreCase:
Regex.Matches( text, @"^(?!.*None).*$", RegexOptions.IgnoreCase ); Regex.IsMatch( text, @"^(?!.*None).*$" , RegexOptions.IgnoreCase );