String is alpha

OSCC · JavaScript, String, Regexp · Dec 31, 2020

Checks if a string contains only alpha characters.

const isAlpha = str => /^[a-zA-Z]*$/.test(str);
isAlpha('sampleInput'); // true
isAlpha('this Will fail'); // false
isAlpha('123'); // false

Recommended snippets