[latex3-commits] [git/LaTeX3-latex3-latex3] gh590: Document use of l3regex to make tl with arbitrary catcodes [ci skip] (9ef29b191)

Bruno Le Floch blflatex at gmail.com
Tue Apr 27 12:15:52 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : gh590
Link       : https://github.com/latex3/latex3/commit/9ef29b19137d87fa71a8fe6b88510e7f4913f5a2

>---------------------------------------------------------------

commit 9ef29b19137d87fa71a8fe6b88510e7f4913f5a2
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Tue Apr 27 12:14:56 2021 +0200

    Document use of l3regex to make tl with arbitrary catcodes [ci skip]


>---------------------------------------------------------------

9ef29b19137d87fa71a8fe6b88510e7f4913f5a2
 l3kernel/l3regex.dtx | 9 +++++++++
 l3kernel/l3token.dtx | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index e533287c6..e2b973c08 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -492,6 +492,15 @@
 % \end{verbatim}
 % results in \cs{l_my_tl} holding |first,\emph{second},first,first|.
 %
+% Regex replacement is also a convenient way to produce token lists
+% with arbitrary category codes.  For instance
+% \begin{verbatim}
+% \tl_clear:N \l_tmpa_tl
+% \regex_replace_all:nnN { } { \cU\% \cA\~ } \l_tmpa_tl
+% \end{verbatim}
+% results in \cs[no-index]{l_tmpa_tl} containing the percent character
+% with category code~$7$ (superscript) and an active tilde character.
+%
 % \section{Pre-compiling regular expressions}
 %
 % If a regular expression is to be used several times,
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index a0830547f..533eee4df 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -146,6 +146,8 @@
 %   and other values raise an error. The \meta{charcode} may be any one valid
 %   for the engine in use.
 %   Active characters cannot be generated in older versions of \XeTeX{}.
+%   Another way to build token lists with unusual category codes is
+%   \cs{regex_replace:nnN} |{.*}| \Arg{replacement} \meta{tl~var}.
 %   \begin{texnote}
 %     Exactly two expansions are needed to produce the character.
 %   \end{texnote}





More information about the latex3-commits mailing list.