1 // Thanks to https://regex101.com
2 function regexpCapture (str: string, regex: RegExp, maxIterations = 100) {
5 let result: RegExpExecArray[] = []
7 // tslint:disable:no-conditional-assignment
8 while ((m = regex.exec(str)) !== null && i < maxIterations) {
9 // This is necessary to avoid infinite loops with zero-width matches
10 if (m.index === regex.lastIndex) {