I'm playing around a bit with the \tl_set_rescan:Nnn function (originally to make this answer more concise), but I'm struggling to make even pretty simple uses of this function work.
Say we want to make all \ characters letters and spaces have their usual catcode. As far as I understand, the following code should produce identical outputs:
\documentclass{article} \usepackage{expl3} \begin{document} \ExplSyntaxOn \group_begin: \char_set_catcode_escape:N \~ ~char_set_catcode_letter:N ~\ ~char_set_catcode_space:n {32} ~tl_set:Nn ~l_tmpa_tl {<\verb|\LaTeX| \LaTeX>} ~tl_show:N ~l_tmpa_tl ~group_end: %%%%%%%%%% \tl_set_rescan:Nnn \l_tmpa_tl { \char_set_catcode_space:n {32} \char_set_catcode_letter:N \\ } {<\verb|\LaTeX| \LaTeX>} \tl_show:N \l_tmpa_tl \ExplSyntaxOff \end{document} outputs
> \l_tmpa_tl=<\verb|\LaTeX| \LaTeX>. > \l_tmpa_tl=<\verb |\LaTeX |\LaTeX >. The result of the first token list is correct, \ was made a letter character and thus no extra spaces are output after the control sequences. However, in the rescan attempt the control sequences do still exist. Also note the missing space after the second |.
How do you make the second version produce the expected result? Or perhaps a bit more broad, as these functions don't seem to work well with verbatim input, what are the designated use cases for them?