Extracted all the regex patterns to a easily navigable array. Simplified the foreach syntax.