Last active
November 28, 2019 02:35
-
-
Save shisama/eebdaedfcff471177877c1ca7a5ff5c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let regexp = /t(e)(st(\d?))/g; | |
let str = 'test1test2'; | |
str.match(regexp); | |
// Array ['test1', 'test2'] | |
let array = [...str.matchAll(regexp)]; | |
console.log(array[0]); | |
// Array ["test1", "e", "st1", "1"] | |
console.log(array[1]); | |
// Array ["test2", "e", "st2", "2"] | |
for (const arr of str.matchAll(regexp)) { | |
console.log(arr) | |
} | |
// Array ["test1", "e", "st1", "1"] | |
// Array ["test2", "e", "st2", "2"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment