s/// replaces everything that matched on the left with whatever matched on the right. What you want to do is store which one of [c|d] matched, and then put that back into the match, ala
The $1 evaluates to whatever ([bc]) matched (either b or c) and then replaces everything matched on the left with whatever is appropriate on the right.