\documentclass{article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{expl3}
\usepackage{xparse}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ExplSyntaxOn
    \cs_new_protected:Npn \scan_tokens:nNw #1 #2 {
        \__scan_tokens:nnnNw {} {#1} {#1} #2
    }
    
    \cs_new_protected:Npn \scan_tokens:nnw #1 #2 {
        \cs_set:Nn \scan_tokens_action:n {#2}
        \scan_tokens:nNw {#1} \scan_tokens_action:n
    }
    
    \cs_new_protected:Npn \__scan_tokens:nnnNw #1 #2 #3 #4 {
        % #1 = result so far (reversed)
        % #2 = tokens not yet tried
        % #3 = all tokens
        % #4 = code to run on result
        \tl_if_empty:nTF {#2} {
            \exp_args:Nf #4 { \tl_reverse:n {#1} }
        }{
            \exp_last_unbraced:Nf \peek_meaning_remove:NTF {\tl_head:n{#2}}
                { \exp_args:Nf  \__scan_tokens:nnnNw {\tl_head:n{#2}#1} {#3} {#3} #4 }
                { \exp_args:Nnf \__scan_tokens:nnnNw {#1}   {\tl_tail:n{#2}} {#3} #4 }
        }
    }
\ExplSyntaxOff

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ExplSyntaxOn
    \NewDocumentCommand \GrabDigits {} {
        \scan_tokens:nnw {1234567890} {
            (##1)
        }
    }
    
    \NewDocumentCommand \GrabModifiers {} {
        \scan_tokens:nnw {!*^} {
            (\tl_to_str:n{##1})
        }
    }
\ExplSyntaxOff

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
    
    \GrabDigits 76543xyz
    
    \GrabModifiers ^!^*$x$
    
\end{document}
