Added snippet for isAlphabetOnly

This commit is contained in:
Sujit Singh
2020-12-24 13:20:27 +05:30
parent 85dd2de7a9
commit 4e22f9cb9a

View File

@ -0,0 +1,18 @@
---
title: isAlphabetOnly
tags: string,regexp,beginner
---
Checks if a string contains only alphabetic characters.
- Use `RegExp.prototype.test()` to check if the input string matches against the alphabetic regexp pattern.
```js
const isAlphabetOnly = input => /^[a-zA-Z]*$/.test(input)
```
```js
isAlphabetOnly('sampleInput'); // true
isAlphabetOnly('this Will fail'); // false
isAlphabetOnly('123'); // false
```