Is there an existing macro that "translate" tokens using some code ? For example :
\def\code{{{a,b},{b,c},{c,a}}}
\translate[\code]{caac} % => would typeset "abba"
or even better something like that :
\def\code{{{ab,ba},{ac,ca},{b,c}{c,b}}}
\translate[\code]{abbcac} % => would typeset "bacbca"
The syntax for the code definition is not important.
If there is no such macro, any proposition is welcomed to obtain an efficient solution to this problem.
Thank you :)

etoolboxto replace certain tokens in a macro. – bodo Jul 19 '12 at 16:17