Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id s7DGumRt031240 for ; Wed, 13 Aug 2014 18:56:49 +0200 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx006) with ESMTPS (Nemesis) id 0MXV4g-1WwFlF0TGY-00WZcX for ; Wed, 13 Aug 2014 18:56:43 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id s7DGrlIq006714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Aug 2014 18:53:47 +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 s7DE2esL007563; Wed, 13 Aug 2014 18:53:47 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 11309140 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 13 Aug 2014 18:53:47 +0200 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id s7DGrkTr008918 for ; Wed, 13 Aug 2014 18:53:46 +0200 Received: from mail-qa0-f47.google.com (mail-qa0-f47.google.com [209.85.216.47]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id s7DGrPv5006543 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Wed, 13 Aug 2014 18:53:28 +0200 Received: by mail-qa0-f47.google.com with SMTP id i13so15430qae.6 for ; Wed, 13 Aug 2014 09:53:24 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.224.80.10 with SMTP id r10mr9053128qak.24.1407948804725; Wed, 13 Aug 2014 09:53:24 -0700 (PDT) Received: by 10.96.131.78 with HTTP; Wed, 13 Aug 2014 09:53:24 -0700 (PDT) References: <53EB330F.8050302@clear.net.nz> <53EB3F66.2060802@morningstar2.co.uk> Content-Type: text/plain; charset=UTF-8 Message-ID: Date: Wed, 13 Aug 2014 18:53:24 +0200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch Subject: Re: l3regex suggestion To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <53EB3F66.2060802@morningstar2.co.uk> 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:6lgGIZTr8+g=:ClweGeMQM9UBwPdozB/9Yq8T9A WYEqYZLPwtaSQ76mlRkZJ0KbgM6hPDIkJ/7J8h7jWhtjCEcrHEl7SDitDeHNpo2xUJiB8nhe5 GgCGo6ZNnYQTWeNQCD76rJobO7xUNeNZKnArdpa46zh+nAkTTDYVz3GHBR6f2GoKFClSo00I3 tMwyOOTf2OZ0jx53cfTslUQkspzAoGKXhf0AxCQXIWGd00Q8Cds7ptY0vsyRclkAFU0Hhk/Ur sgv+UjH8GBHeuBewPsE/KCRGJsKTe9WTzbwI1Vh8UtUMx2i0QGlrV5//51HAKA3U+YFTOI27J E4PLwkgcDuCO42yXCOkDx4MalmY3HiY2rBCz5sPFmpI3uAbVMsLEqgmZNHkTkJeKiv1jOcpxV ozLmpkruf5o02ALh2DDgbDhbXb5ZHlwJC0mPtsekN+6f2Hi8UCbrIcwFKHo2krIgEhiTiekdS 9cFtMYDupcBrPS6fgwd7getqde8w/YjNy1tcXbAazc9YoGlG1o1eRaL2BGibCBEcV8WmgdwU4 qsp3+scqR7a+ywGCpGjqJj1Vgd1G3n+BoWGCvH+8OrVzd/B1SsAmslOz2cLRBW8pnyDkdOf3o QVBfnzlVafDQBFg/52/S8LKrZ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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 I can confirm that Joseph's analysis of the situation. l3regex provides no variant defined through \cs_generate_variant:Nn, but they can be defined in your own code. -- Bruno