regex 'unmached parenthesis' and unterminated group' fix