Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nitayneeman/b9cbf45a70142c5e6eea718885597e82 to your computer and use it in GitHub Desktop.
Save nitayneeman/b9cbf45a70142c5e6eea718885597e82 to your computer and use it in GitHub Desktop.
const regex = /t(e)(st(\d?))/g;
const result = 'test1test2'.matchAll(regex);
const resultAsArray = [...result];
console.log(resultAsArray[0]); // ["test1", "e", "st1", "1", index: 0, input: "test1test2", groups: undefined]
console.log(resultAsArray[1]); // ["test2", "e", "st2", "2", index: 5, input: "test1test2", groups: undefined]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment