in reply to Providing regex using an array

You have unbalanced parens in your if, the semicolon on that line should be a closing paren.

If I understand correctly what your code is trying to do, you may be interested in my tutorial Building Regex Alternations Dynamically.