How this tool computes its result
The tool constructs `new RegExp(pattern, flags)` directly from your input and runs it against the test string using the native JavaScript regex engine. When the "g" flag is present, it loops calling regex.exec(input) repeatedly, manually advancing regex.lastIndex by 1 whenever a match is empty-string (to avoid an infinite loop on patterns like `x*`), collecting each match's full text, start index, and capture groups. Without "g", it runs exec() once and returns at most one match.
