Generate unique match array for regex functions.

Reusing this state broke nested replacer functions in regexes.