The string can be like one of the following:
a(b,c) a(a(b,c),d) a(a(a(a(a(b,c),d),a(e,f)),g),h) etc
I want to match an unlimited number of
Java's standard regex lib does not support recursion, so you can't match such general nested constructs with it.
But in flavors that do support recursion (Perl, PCRE, .NET, etc) you can use expressions like:
\w+(?:\((?R)(?:,(?R))*\))?