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])
//> Array ["test1", "e", "st1", "1"]
//> Array ["test2", "e", "st2", "2"]