Skip to content

Instantly share code, notes, and snippets.

@shisama
Last active April 24, 2019 01:00
Show Gist options
  • Save shisama/b558f90ceb7f6f489e466a494a4e4117 to your computer and use it in GitHub Desktop.
Save shisama/b558f90ceb7f6f489e466a494a4e4117 to your computer and use it in GitHub Desktop.
String#matchAll - New JavaScript Features in Node.js v12
const regexp = /t(e)(st(\d?))/g;
const str = 'test1test2';
const array = [...str.matchAll(regexp)];
console.log(array[0])
// ['test1', 'e', 'st1', '1', index: 0, input: 'test1test2', groups: undefined]
console.log(array[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