Link to home
Start Free TrialLog in
Avatar of tmajor99
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
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

The easiest way to do this is look for a number...

/[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/
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial