Merge pull request #1716 from sujit510/feature/isAlphabetOnly

Added snippet for isAlphabetOnly
This commit is contained in:
Angelos Chalaris
2020-12-31 14:01:57 +02:00
committed by GitHub

18
snippets/isAlpha.md Normal file
View File

@ -0,0 +1,18 @@
---
title: isAlpha
tags: string,regexp,beginner
---
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
```