Regex To Match A String That Doesn’t Contain A Specfic Character

A regular expression that can be used to match anything that doesn’t have a specific character, like dot(.), comma(,), dash(-), whitespace, etc.

Note that don’t forget to replace the dot(.) with another character in the following regex.

/^[^.]+$/g

Matches:

  • I’m regex pattern

Non-matches:

  • I’m regexpattern.com
  • file.exe

See Also:

Regex Is Copied!