in reply to greedy subexpression between two nongreedy ones
Indeed it seems you are trying to accomplish too much with a single regex! But here's another alternative:
s/(?&COMMA)(?:.*?(?:((?&CEEDEE)).*?(?&COMMA)|(?&COMMA)()))(?(DEFINE)(? +<COMMA>,)(?<CEEDEE>cd))/=$+=/;
|
|---|