The requirement marking function used test() then replace() on the same global-flag regex. test() advances lastIndex, so replace() starts from the wrong position and can miss the first match. Replace with direct replace() + string comparison to detect changes. Also drop unnecessary global flag from done-check patterns that only need existence testing, and eliminate the duplicate regex construction for the table pattern. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>