This is the code, it compiles (please, don't ask me what it's for):
\documentclass{minimal}
\begin{document}
\ExplSyntaxOn
\newcommand\foo[1]{
\tl_set:Nn \l_ebnf_tl { }
\tl_set_rescan:Nno \l_ebnf_tl {}{#1}
\l_ebnf_tl
}
\ExplSyntaxOff
\foo{ \textdollar}
\end{document}
However, if I modify the line with textdollar to this one (I just remove the leading space):
\foo{\textdollar}
It prints this:
! Undefined control sequence.
\l_ebnf_tl ->\?
-cmd \textdollar \?\textdollar
l.10 \foo{\textdollar}
What is this about and how to fix? I don't need this space character over there.
\tl_set_rescanwith two arguments: https://tex.stackexchange.com/questions/496965/how-do-use-setup-in-tl-set-rescannnn-to-replace-scantokens – yegor256 Jun 29 '23 at 19:59\textdollar? – egreg Jun 29 '23 at 20:05o? This expands#1once and break if#1starts with\textdollar. – Ulrike Fischer Jun 29 '23 at 20:55