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

Bruno Le Floch blflatex at gmail.com
Tue Apr 27 15:59:07 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/fa31de2edaf79f555c2e9d49ccfdbb88c28518d8

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

commit fa31de2edaf79f555c2e9d49ccfdbb88c28518d8
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]


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

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

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index 0cdd3d453..2a6a95a7c 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -499,6 +499,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.