Files
30-seconds-of-code/snippets/is-alpha.md
Angelos Chalaris 61200d90c4 Kebab file names
2023-04-27 21:58:35 +03:00

22 lines
478 B
Markdown

---
title: String is alpha
tags: string,regexp
cover: coffee-phone-tray-3
firstSeen: 2020-12-31T14:01:42+02:00
lastUpdated: 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.
```js
const isAlpha = str => /^[a-zA-Z]*$/.test(str);
```
```js
isAlpha('sampleInput'); // true
isAlpha('this Will fail'); // false
isAlpha('123'); // false
```