Slide 9
Slide 9 text
9
String#matchAll
● RegExp#exec だとループ処理を書く必要がある
let match;
while (match = reg.exec(str)) {
// reg.lastIndex プロパティを書き換えることで状態を保持している
console.log(match);
}
// -> ["test1", "e", "st1", "1", index: 0, input: "test1test2",
groups: undefined]
// -> ["test2", "e", "st2", "2", index: 5, input: "test1test2",
groups: undefined]