Regular expression - Negation



Regular expression is a language that does not have a NOT operator but it has some negative construct


Negative Class

^ will negate the class, ie capture until not this characters


  • matches any character other than a, b, or c.
  • matches any single character that is not a lowercase letter from a to z. |
  • all character except the character p

Negative Look

  • Negative lookahead - do we have a pattern ahead
  • Negative lookbehind - do we have a pattern behind

See Regexp - Look-around group (Assertion) - ( Lookahead | Lookbehind )


  • Positive lookahead: Capture only if the string has a ?

Discover More
Regexp - Character Class (Character Set)

A character class defines a domain of permitted characters. character set ASCII characters with square brackets where: [ is the start character class definition ] is the end character class...

Share this page:
Follow us:
Task Runner