I'm trying to matching something like:
aabbaCaabaCabCbaCCC, grouped as (aabbaCaabaCabCba)(CCC), i.e. with any final Cs matched as a separate group.
I assumed I could use lazy matching somehow, but nothing I've tried worked. For example:
/(a+|b+|C*?)+(C*)/ and /(a+|b+|C*)+?(C*)/ match too much or not enough; they include the CCC in the first group, or they only match the initial aa.
This is in JavaScript by the way.