regex - Split into words by an uncommented comma that is not inside matching parentheses -


consider following string:

blah, foo(a,b), bar(c,d), yo 

i want extract list of strings:

blah foo(a,b) bar(c,d) yo 

it seems me should able use quote words here, i'm struggling regex. can me out?

perl has little thing regex recursion, might able for:

  • either bare word blah containing no parentheses (\w+)

  • a "call", \w+\((?r)(, *(?r))*\)

the total regex (\w+(\((?r)(, ?(?r))*\))?), seems work.


Comments