2

How does one extract substrings from a non-explicit token list?

\documentclass{article}
\usepackage{expl3}

\begin{document}

\ExplSyntaxOn

\tl_new:N \l_my_tl
\seq_new:N \l_my_seq

\tl_set:Nn \l_my_tl { foot }

\regex_extract_once:nnNTF { foo } { foot }
  \l_my_seq
  { true }
  { false }

\par

\regex_extract_once:nnNTF { foo } { \l_my_tl }
  \l_my_seq
  { true }
  { false }

\end{document}

The first extraction command has an explicit 'foot' and succeeds; I hoped the second would too, expanding \t_my_tl, but that is not what happened. Output:

true
false
0

1 Answer 1

3

You have to use the value of the token list variable:

\documentclass{article}
\usepackage{expl3}

\begin{document}

\ExplSyntaxOn

\tl_new:N \l_my_tl
\seq_new:N \l_my_seq

\cs_generate_variant:Nn \regex_extract_once:nnNTF { nV }

\tl_set:Nn \l_my_tl { foot }

\regex_extract_once:nnNTF { foo } { foot }
  \l_my_seq
  { true }
  { false }

\par

\regex_extract_once:nVNTF { foo } \l_my_tl
  \l_my_seq
  { true }
  { false }

\end{document}

This prints

true
true

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .