Matching balanced braces is harder than you think. This is a job for a module (Regexp::Common::balanced). You do not have to do the whole job with one regex. Write a subroutine (possibly a recursive one).
Bill
Comment on Re: Perl-Replacement of comma in between the matched Patterns