I'm banging my head against a wall with a regular expression. I'm trying to define an expression that excludes exactly this text 'System' (case insensitive), but can contain the word 'System' providing it's no开发者_如何学Got just that.
Examples:
- System == INVALID
- SYSTEM == INVALID
- system == INVALID
- syStEm == INVALID
- asd SysTem == Valid
- asd System asd == Valid
- System asd == Valid
- asd System == Valid
- asd == Valid
Try this:
^(?!system$)
Or this to match the whole line:
^(?!system$).*$
The regex has a negative look-ahead on its beginning, which doesn't match if "system" is the entire string.
Reject if it matches ^system$
(make sure i
flag is ON).
^$|^.{1-5}$|.{7}|^[^s]|^.[^y]|^..[^s]|^...[^t]|[^e].$|[^m]$
But use amarghosh's answer if you can.
(updated as per suggestion below)
精彩评论