Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nitayneeman/5520d633ed89a87617c092d5751a0c03 to your computer and use it in GitHub Desktop.
Save nitayneeman/5520d633ed89a87617c092d5751a0c03 to your computer and use it in GitHub Desktop.
const regex = /t(e)(st(\d?))/g;
const str = 'test1test2';
// Using spread operator
const array = [...str.matchAll(regex)];
// Using `from` method
const array2 = Array.from(str.matchAll(regex));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment