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

21 lines
452 B
Markdown

---
title: isAlpha
tags: string,regexp,beginner
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
```