Files
30-seconds-of-code/snippets/isAlphabetOnly.md
2020-12-24 13:20:27 +05:30

419 B

title, tags
title tags
isAlphabetOnly string,regexp,beginner

Checks if a string contains only alphabetic characters.

  • Use RegExp.prototype.test() to check if the input string matches against the alphabetic regexp pattern.
const isAlphabetOnly = input => /^[a-zA-Z]*$/.test(input)
isAlphabetOnly('sampleInput'); // true
isAlphabetOnly('this Will fail'); // false
isAlphabetOnly('123'); // false