category | created | title | updated |
---|---|---|---|
Validator |
2020-06-07 |
Check if a string contains only letters |
2021-10-13 |
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