Regex To Match A String That Doesn’t End With Given Suffix

A regular expression to match a string that doesn’t end with the given suffix.

/.*(?<!MYSUFFIX)$/

Matches:

  • This Is A String MYSUFFIX.
  • This Is A String MY.
  • This Is A String SUFFIX.

Non-matches:

  • This Is A String MYSUFFIX

See Also: