Skip to content

Instantly share code, notes, and snippets.

@mark-ingenosity
Created October 1, 2021 20:11
Show Gist options
  • Select an option

  • Save mark-ingenosity/887b6473f9cb2b4005b685de122456d7 to your computer and use it in GitHub Desktop.

Select an option

Save mark-ingenosity/887b6473f9cb2b4005b685de122456d7 to your computer and use it in GitHub Desktop.
match "does NOT contain EXPRESSION"

matches does NOT contain EXPRESSION

^((?!EXPRESSION.)*$

Explanation:

  • ^the beginning of the string, ( group and capture to \1 (0 or more times (matching the most amount possible)),
  • (?! look ahead to see if there is not, hede your string,
  • ) end of look-ahead, . any character except \n,
  • )* end of \1 (Note: because you are using a quantifier on this capture, only the LAST repetition of the captured pattern will be stored in \1)
  • $ before an optional \n, and the end of the string

matches does NOT start with EXPRESSION

^(?!EXPRESSION).*$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment