Explanations
I format a moroccan RIB (Relevé d’identité bancaire for “Bank account number”) to display it as a nice rendering. I need to take each part of the RIB to embrace it with a specific label.
But, for the moment, I have to manually parse the RIB.
MWE
For the moment I have the following MWE:
\documentclass{article}
\usepackage[load-configurations = abbreviations]{siunitx}
\newcommand{\textunderbrace}[2]{%
\ensuremath{\underbrace{\text{#1}}_{\text{#2}}}%
}
\newcommand{\textoverbrace}[2]{%
\ensuremath{\overbrace{\text{#1}}^{\text{#2}}}%
}
\begin{document}
\textunderbrace{PPPP}{pays} \textoverbrace{\textunderbrace{BBB}{banque} \textunderbrace{VVV}{ville} \textunderbrace{NNNNNNNNNNNNNNNN}{Numéro} \textunderbrace{CC}{clé}}{RIB}
\end{document}
Rendering
Which gives the following rendering:
The problem
As you see in the code, I manually set the country code, the bank code, the city code in a specific row.
The question
So, how can I, from a command like \moroccanrib
parse the 4 first chars in \country
variable, the 5th-7th char in \bank
variable, etc?