Depending on how you define "name", you could go with checking it against this regex:
^\w+$
However, this will allow numbers and underscores. To rule them out, you can do a second test against:
[\d_]
and make your check fail on match. These two could be combined as follows:
^(?:(?![\d_])\w)+$
But for regex performance reasons, I would rather do two separate checks.
From the docs:
\w
When the LOCALE
and UNICODE
flags are
not specified, matches any
alphanumeric character and the
underscore; this is equivalent to the
set [a-zA-Z0-9_]
. With LOCALE
, it will
match the set [0-9_]
plus whatever
characters are defined as alphanumeric
for the current locale. If UNICODE
is
set, this will match the characters
[0-9_]
plus whatever is classified as
alphanumeric in the Unicode character
properties database.