GitHub 6248★

Check if a string contains only letters

JavaScript version

const isAlpha = (str) => /^[A-Z]+$/i.test(str);

TypeScript version

const isAlpha = (str: string): boolean => /^[A-Z]+$/i.test(str);

Examples

isAlpha('helloworld'); // true
isAlpha('HelloWorld'); // true
isAlpha('hello world'); // false
isAlpha('0123456789'); // false
Follow me on and to get more useful contents.