1let str = '<h1>Hello, world!</h1>';
2let regexp = /<(.*?)>/g;
3
4let matchAll = str.matchAll(regexp);
5
6alert(matchAll); // [object RegExp String Iterator], not array, but an iterable
7
8matchAll = Array.from(matchAll); // array now
9
10let firstMatch = matchAll[0];
11alert( firstMatch[0] ); // <h1>
12alert( firstMatch[1] ); // h1
13alert( firstMatch.index ); // 0
14alert( firstMatch.input ); // <h1>Hello, world!</h1>