-1

I need a regexp that will match everything except a single constant (case ignored)

Example for constant ALL, should match words like: dog, MOUSE, mall, alligator. But it shouldn't match: all, ALL, alL.

Marius
  • 3,253
  • 5
  • 25
  • 29
  • @KlasLindbäck: No, that's *not* a duplicate. "Not containing" a word is not the same as "not being" a word. – Tim Pietzcker Mar 07 '14 at 13:40
  • @Tim You are right. You would have to add placeholders for start/end of string AND case insensitivity to make it a duplicate. (Retracting my close vote) – Klas Lindbäck Mar 07 '14 at 13:43

1 Answers1

1
(?si)^(?!all$).*

will match any string except all (case-insensitively).

(?i) makes the regex case-insensitive, (?s) allows the dot to match any character, including newlines. If you don't expect newlines in your input, you can remove the s.

See it live on regex101.com.

Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561