LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: Mailing list for the LaTeX3 project <[log in to unmask]>
Date: Wed, 13 Aug 2014 21:42:39 +1200
MIME-version: 1.0
Reply-To: Mailing list for the LaTeX3 project <[log in to unmask]>
Content-type: text/plain; charset=ISO-8859-1; format=flowed
From: aparsloe <[log in to unmask]>
Message-ID: <[log in to unmask]>
Content-transfer-encoding: 7bit
Parts/Attachments: text/plain (27 lines)
I have been using l3regex and tripped on the following circumstance. Suppose

\tl_set:Nn \l_tmpa_tl { abcdef }


\regex_replace_all:nnN { cd } { 12 } \l_tmpa_tl

results in \l_tmpa_tl containing ab12ef, but there is no built-in 
function for the analogous match or extract function. This was 
disconcerting for a moment, to discover that I could replace text but 
couldn't match it. Of course I can, but it means resorting to 
\exp_args:Nno as in

\exp_args:Nno \regex_match:nnTF { cd } \l_tmpa_tl { true } { false }

It would be consistent with the presence of \regex_replace_all:nnN and 
\regex_replace_all:NnN if there were corresponding functions, 
\regex_match:nN and \regex_match:NN, and similarly for extract.

In the context in which I was working, the token list variable 
(analogous to \l_tmpa_tl above) is set to a mathematical formula 
elsewhere in the code. The formula is most naturally handled in this way 
as a token list variable rather than as a token list.