How can I create a macro
\split{ABC}
that outputs
where the formatting of the characters are made with another macro, i.e.
\formatchar{A}
where
\def\formatchar#1{{\color{red}#1}}
for any string length?
I tried to modify the code in Split a character string n by n
\documentclass{article}
\usepackage{xstring}
\def\split#1#2{%
\StrSplit{#2}{1}\tempa\tempb
x%
\tempa\let\tempa\empty
\unless\ifx\tempb\empty\def\tempa{|\split{1}\tempb}\fi
y%
\tempa
}
\begin{document}
\split{1}{ABCD}
\end{document}
And I get x and y before and after (since I failed limiting with a command and }) but I cannot get it to format properly. Also I would like to avoid the {1} in call, and use
\split{ABCD}
only. It is always 1-charater splits.
Any help is much appreciated!