Regex To Match A String That Doesn’t Start With Given Prefix

A regular expression to match a string that doesn’t start with the given prefix.

/^(?!MYPREFIX).+/

Matches:

  • PREFIX This Is A String.
  • M This Is A String.

Non-matches:

  • MYPREFIX This Is A String.

See Also: