Files
30-seconds-of-code/snippets/isAlpha.md
Isabelle Viktoria Maciohsek 27c168ce55 Bake date into snippets
2021-06-13 13:55:00 +03:00

452 B

title, tags, firstSeen, lastUpdated
title tags firstSeen lastUpdated
isAlpha string,regexp,beginner 2020-12-31T14:01:42+02:00 2020-12-31T14:01:42+02:00

Checks if a string contains only alpha characters.

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