Regular Expression To Match Non-numeric Strings

Category: Strings

A Regular Expression to match a non-numeric string that is not composed entirely of numbers. Useful for usernames, nicknames, unique identifiers, and more.

Note that this regular expression is different from Regular Expression To Match Non-numeric Characters, which strictly restricts numbers from appearing in strings.

/(?!^\d+$)^.+$/g

Matches:

  • abc
  • a123b
  • abc123

Non-matches:

  • 1
  • 12345
  • 123456

See Also:

Expression Flags

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