query-replace-regexp : \(A\)\|\(B\)\|\(C\)
... with: \,(cond((match-end 1)"B")((match-end 2)"C")("A"))