tmajor99
asked on
Regular Expression to detect if only alpha chars provided
I need a regular expression that will check a string that contains only ALPH characters (A-Z) and special characters.
Compliant
---------------
NA ---> Match
NA1234 ----> Not matched because has numbers
UN123 ----> Not matched because has numbers
23u ----> Not matched because has numbers
na -----> Match
N/A ------> Match
n-A ------> Match
Compliant
---------------
NA ---> Match
NA1234 ----> Not matched because has numbers
UN123 ----> Not matched because has numbers
23u ----> Not matched because has numbers
na -----> Match
N/A ------> Match
n-A ------> Match
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
/[1-9]/g
...and fail out if it returns a result. Anything else is alpha or a character. If you want to match only certain special characters, this may not be the best way.
You can test the RegEx here: https://regex101.com/