I need a regex that matches the alphanumeric patterns except totally numeric ones.
asdfgesod valid 1asdndwdd valid asd124asd valid a2asd43bd valid 123346678 invalid
/^[a-z0-9]*[a-z][a-z0-9]*$/i
Broken down:
^[a-z0-9]* - String starts with any number (including zero) of alphanumeric characters
[a-z] - String has an a-z character
[a-z0-9]*$ - String ends with any number (including zero) of alphanumeric characters
i at the end if you don't want (uppercase) A-Z to be considered alpha characters.You can try:
/^(?![0-9]+$)[a-z0-9]+$/i
[a-z0-9]+$ ensures the string is made of only alphanumeric characters.
The negative lookahead (?![0-9]+$) ensures the string is not all numeric.
A solution would be to first check if the string contains only digits, if not check rest of the string. The following regex would do that:
^(?![\d]+$)[a-z0-9]+$
See it in action here: http://regexr.com?2v8n5