What is the regex to get strings with one or more word characters except strings with digit only characters? For example, "word", "word1" match the regex but "1" doesn't. Thanks!
Asked
Active
Viewed 55 times
1 Answers
-1
Try this:
/\A(?!\d+\z)\w+\z/
Description:
\A
- start of string(?!\d+\z)
- negative lookahead
Using ?!
means not matching given pattern
\d+
- one or more digits
\z
- end of string
So if only digit(s) - pattern will not match
\w+
- one or more word characters\z
- end of string

mechnicov
- 12,025
- 4
- 33
- 56