// ES2022 const matchObj = /(a+)(b+)/d.exec('aaaabb'); console.log(matchObj); /* Output - ['aaaabb', 'aaaa', 'bb', index: 0, input: 'aaaabb', groups: undefined, indices: Array(3)] */