Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id s7DAcNgV029656 for ; Wed, 13 Aug 2014 12:38:24 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx110) with ESMTPS (Nemesis) id 0M8qSu-1X7f7d11bw-00C7Xl for ; Wed, 13 Aug 2014 12:38:18 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id s7DAZoji022412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Aug 2014 12:35:50 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id s7D92TS0016363; Wed, 13 Aug 2014 12:35:49 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 11271101 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 13 Aug 2014 12:35:49 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id s7DAZnFV018587 for ; Wed, 13 Aug 2014 12:35:49 +0200 Received: from smtp3.easily.co.uk (smtp3.easily.co.uk [91.194.151.18]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id s7DAZJ74022157 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 13 Aug 2014 12:35:21 +0200 Received: from [139.222.112.180] (port=53092 helo=[139.222.112.180]) by smtp3.easily.co.uk with esmtpa (Exim 4.43) id 1XHVtm-0001Or-Tt for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 13 Aug 2014 11:35:18 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 References: <53EB330F.8050302@clear.net.nz> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <53EB3F66.2060802@morningstar2.co.uk> Date: Wed, 13 Aug 2014 11:35:18 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: l3regex suggestion To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <53EB330F.8050302@clear.net.nz> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:rvm2SjvcLc0=:fSFdvKL9CariMCymdSu/h1OSlF v/kfhl1BU413IfmrEu5+hKJzVshQXhLReSS+aPE1WKSQAPHCqsjmlQMS/YI1vMHutoNbEFytD UVt50GDtBIvo6+g8wOfcOeUAQ+RamJ33lvCQG/T8d6Ehhn3BTxupqtyuU5ALFMCs2qGmfK86a o3010wVyPdm2uY1nzkiJxD7Mxsr2lYCXxgJ3ZXtfGYdr8aIHPDsjjGTNTovuomJjTOwLBZ/vi 3+3V3N+VsTpNKlOXVjOhIpV7bEMRFI/pBtGDxEWT9Gpq8epf6oy35pfu1wqURD21UeE8kPp5n 74vSFp6dEgF1pVoFA07ueY6Rfh10CjHlnnnEgywNQUgr7tzSHzcqz33Gwg1feoDZqcg9rB7s4 wVv53gvb4hce6/jOy2ou7cHrwYtXRoLS7dQmjB1PTUc2i4sFEw8cbB/ZLq8MWHT8HPM0S1Jvw XOnp4vILir3N/QNjKwYB3PUNNtewW4unOdOrExU7hgMAOCxVjoeyOyWsW/6PNR19bAc2IvJIp 2WMNYD19Jn/xt3E/ACIfqbCLzJaOELhOPYQyyb07iu5Je31Kt/pxR3kjiC0yQaZmWnYMAjMlY AvQ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status: X-Keywords: X-UID: 7557 On 13/08/2014 10:42, aparsloe wrote: > I have been using l3regex and tripped on the following circumstance. > Suppose > > \tl_set:Nn \l_tmpa_tl { abcdef } > > Then > > \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. > > Andrew There's a difference here between the two situations: in the replace case, you need to have an N-type argument as you've got to have a tl to set at the end of the process. On the other hand, in the case of matching it's unimportant if the tokens are given in a tl or are given explicitly. So \cs_generate_variant:Nn \regex_match:nnTF { nV } \regex_match:nVTF { cd } \l_tmpa_tl { true } { false } would be my preference here. (We don't claim to define all possible variants up-front, but there is nothing stopping you adding ones which are useful.) -- Joseph Wright