Skip to content

Commit 268e563

Browse files
authored
Update isAlphaNumeric.md
1 parent 6e1c82d commit 268e563

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

snippets/isAlphaNumeric.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: isAlphaNumeric
3-
tags: string,regexp,intermediate
3+
tags: string,regexp,beginner
44
---
55

66
Checks if a string contains only alphanumeric characters.
77

8-
Use `String.prototype.match()` to check if input string matches against alphanumeric regex pattern.
8+
Use `RegExp.prototype.test()` to check if input string matches against alphanumeric regex pattern.
99

1010
```js
11-
const isAlphaNumeric = (str) => !!str.match(/^[a-z0-9]+$/gi);
11+
const isAlphaNumeric = str => /^[a-z0-9]+$/gi.test(str);
1212
```
1313

1414
```js

0 commit comments

Comments
 (0)