You're right, should have chosen better variable names, or at least add some comments:
Color format is: \x03([0-9]{1,2}(,[0-9]{1,2})?)?
So:
e: escape -> if true, we have met an escape char (\x03) and are still striping.
c: comma -> if we passed the comma yet or not
d: the number of digits we already striped (maximum 2 each time)