Adapting Joseph's answer in Extract the numerical and non-numerical portion from text to count a non-numerical portion from a text. The idea behind my method is to use regex to seperate the numerical and symbolic part from a text (like in the answer), and store the symbolic and numerical parts as key names and values respectively in a property list. This works perfectly fine. The problem I ram into is when an input is a control sequence like \alpha and sub/superscipt _ and ^. The code shows this issue e.g. \test{\alpha} does not produce \alpha (the symbol).
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\test}{ m }
{
\simon_test:n {#1}
}
\cs_new:Npn \simon_test:n #1
{
\prop_clear:N \l_tmpa_prop
\exp_args:NNn \prop_put:Nnn \l_tmpa_prop {#1} {} % the value is of no importance for the mwe
\prop_map_inline:Nn \l_tmpa_prop
{
##1
}
}
\ExplSyntaxOff
\begin{document}
$\test{a_n}$ should be $a_n$
$\test{b^2}$ should be $b^n$
$\test{\alpha}$ should be $\alpha$
\end{document}
I believe this is due to l3prop stores the key names as strings.
The use of a property list in this way is an core part of my code (I could rewrite it to use two sequences, but I found property list easier to use). Is there a way to overcome this, or do I have to rewrite my code?

