Refactor into a loop over an array of regexes