Test, validate and match regular expressions
This regex matches commas outside of parentheses, along with fully balanced parenthesized groups. The second alternation handles nested parentheses up to three levels deep, allowing commas within function calls or subqueries to be skipped. Commonly used in SQL formatters to split statements at the top level while respecting nested structures.