Can we negate this expression, if no match found to return true for use in regex attributes (MVC dataannotations)?
Pattern should match:
- anything with less than 8 characters OR
- anything with no numbers OR
- anything with no uppercase OR
- anything with no special characters
I want to negate this expression/pattern
[RegularExpression(@"^(.{0,7}|[^0-9]*|[^A-Z]*|[a-zA-Z0-9]*)$")]
I tried ?!
with no success:
[RegularExpression(@"^(?!.{0,7}|[^0-9]*|[^A-Z]*|[a-zA-Z0-9]*)$")]
Refering to this answer: Regex password validation, reverse logic