Update and rename isAlphabetOnly.md to isAlpha.md
This commit is contained in:
18
snippets/isAlpha.md
Normal file
18
snippets/isAlpha.md
Normal 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
|
||||||
|
```
|
||||||
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
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
|
|
||||||
```
|
|
||||||
Reference in New Issue
Block a user