Question

Regex not equal to string

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 not 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
 45  158192  45
1 Jan 1970

Solution

 94

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.

2010-06-03

Solution

 5

Reject if it matches ^system$ (make sure i flag is ON).

2010-06-03