Skip to content

Instantly share code, notes, and snippets.

@batazo
Created July 3, 2022 18:45
Show Gist options
  • Save batazo/cbda1a61d825c823eadd4d0addc56124 to your computer and use it in GitHub Desktop.
Save batazo/cbda1a61d825c823eadd4d0addc56124 to your computer and use it in GitHub Desktop.
RegExp match indices
const fruits ="Fruits:apples, oranges, pears";
const regex = /(apples)/gd;
const matches = [...fruits.matchAll(regex)];
console.log(matches[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment