Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nitayneeman/7fa63c4f009366027a33b59b0393d50c to your computer and use it in GitHub Desktop.
Save nitayneeman/7fa63c4f009366027a33b59b0393d50c to your computer and use it in GitHub Desktop.
const regex = /t(e)(st(\d?))/g;
let matchingValue;
while ((matchingValue = regex.exec('test1test2')) !== null) {
console.log(matchingValue);
}
// Output:
// ["test1", "e", "st1", "1", index: 0, input: "test1test2", groups: undefined]
// ["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