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

Category: Strings

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:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.