Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 488 Bytes

check-if-a-string-contains-only-letters.mdx

File metadata and controls

27 lines (21 loc) · 488 Bytes
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