Files
30-seconds-of-code/snippets/isAlpha.md
2022-12-04 22:20:49 +02:00

494 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
String is alpha string,regexp blog_images/coffee-phone-tray-3.jpg 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