diff options
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3regex.dtx')
-rw-r--r-- | macros/latex/contrib/l3kernel/l3regex.dtx | 73 |
1 files changed, 58 insertions, 15 deletions
diff --git a/macros/latex/contrib/l3kernel/l3regex.dtx b/macros/latex/contrib/l3kernel/l3regex.dtx index 6aef0742a0..3d342960ac 100644 --- a/macros/latex/contrib/l3kernel/l3regex.dtx +++ b/macros/latex/contrib/l3kernel/l3regex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2023-08-11} +% \date{Released 2023-08-29} % % \maketitle % @@ -587,7 +587,11 @@ % while the later require a compiled expression as generated by % \cs{regex_set:Nn}. % -% \begin{function}[TF, added = 2017-05-26]{\regex_match:nn, \regex_match:Nn} +% \begin{function}[TF, added = 2017-05-26] +% { +% \regex_match:nn, \regex_match:nV, +% \regex_match:Nn, \regex_match:NV +% } % \begin{syntax} % \cs{regex_match:nnTF} \Arg{regex} \Arg{token list} \Arg{true code} \Arg{false code} % \end{syntax} @@ -600,7 +604,11 @@ % leaves \texttt{TRUE} then \texttt{FALSE} in the input stream. % \end{function} % -% \begin{function}[added = 2017-05-26]{\regex_count:nnN, \regex_count:NnN} +% \begin{function}[added = 2017-05-26] +% { +% \regex_count:nnN, \regex_count:nVN, +% \regex_count:NnN, \regex_count:NVN +% } % \begin{syntax} % \cs{regex_count:nnN} \Arg{regex} \Arg{token list} \meta{int var} % \end{syntax} @@ -657,7 +665,10 @@ % \section{Submatch extraction} % % \begin{function}[noTF, added = 2017-05-26] -% {\regex_extract_once:nnN, \regex_extract_once:NnN} +% { +% \regex_extract_once:nnN, \regex_extract_once:nVN, +% \regex_extract_once:NVN, \regex_extract_once:NVN +% } % \begin{syntax} % \cs{regex_extract_once:nnN} \Arg{regex} \Arg{token list} \meta{seq~var} % \cs{regex_extract_once:nnNTF} \Arg{regex} \Arg{token list} \meta{seq~var} \Arg{true code} \Arg{false code} @@ -688,7 +699,10 @@ % \end{function} % % \begin{function}[noTF, added = 2017-05-26] -% {\regex_extract_all:nnN, \regex_extract_all:NnN} +% { +% \regex_extract_all:nnN, \regex_extract_all:nVN, +% \regex_extract_all:NnN, \regex_extract_all:NVN +% } % \begin{syntax} % \cs{regex_extract_all:nnN} \Arg{regex} \Arg{token list} \meta{seq~var} % \cs{regex_extract_all:nnNTF} \Arg{regex} \Arg{token list} \meta{seq~var} \Arg{true code} \Arg{false code} @@ -711,7 +725,11 @@ % and the \texttt{true} branch is left in the input stream. % \end{function} % -% \begin{function}[noTF, added = 2017-05-26]{\regex_split:nnN, \regex_split:NnN} +% \begin{function}[noTF, added = 2017-05-26] +% { +% \regex_split:nnN, \regex_split:nVN, +% \regex_split:NnN, \regex_split:NVN, +% } % \begin{syntax} % \cs{regex_split:nnN} \Arg{regular expression} \Arg{token list} \meta{seq~var} % \cs{regex_split:nnNTF} \Arg{regular expression} \Arg{token list} \meta{seq~var} \Arg{true code} \Arg{false code} @@ -740,7 +758,10 @@ % \section{Replacement} % % \begin{function}[noTF, added = 2017-05-26] -% {\regex_replace_once:nnN,\regex_replace_once:NnN} +% { +% \regex_replace_once:nnN,\regex_replace_once:nVN, +% \regex_replace_once:NnN,\regex_replace_once:NVN +% } % \begin{syntax} % \cs{regex_replace_once:nnN} \Arg{regular expression} \Arg{replacement} \meta{tl~var} % \cs{regex_replace_once:nnNTF} \Arg{regular expression} \Arg{replacement} \meta{tl~var} \Arg{true code} \Arg{false code} @@ -754,7 +775,10 @@ % \end{function} % % \begin{function}[noTF, added = 2017-05-26] -% {\regex_replace_all:nnN, \regex_replace_all:NnN} +% { +% \regex_replace_all:nnN,\regex_replace_all:nVN, +% \regex_replace_all:NnN,\regex_replace_all:NVN +% } % \begin{syntax} % \cs{regex_replace_all:nnN} \Arg{regular expression} \Arg{replacement} \meta{tl~var} % \cs{regex_replace_all:nnNTF} \Arg{regular expression} \Arg{replacement} \meta{tl~var} \Arg{true code} \Arg{false code} @@ -6518,7 +6542,11 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[TF]{\regex_match:nn, \regex_match:Nn} +% \begin{macro}[TF] +% { +% \regex_match:nn, \regex_match:nV, +% \regex_match:Nn, \regex_match:NV +% } % Those conditionals are based on a common auxiliary defined % later. Its first argument builds the \textsc{nfa} corresponding to % the regex, and the second argument is the query token list. Once we @@ -6530,21 +6558,26 @@ \@@_if_match:nn { \@@_build:n {#1} } {#2} \@@_return: } +\prg_generate_conditional_variant:Nnn \regex_match:nn { nV } { T , F , TF } \prg_new_protected_conditional:Npnn \regex_match:Nn #1#2 { T , F , TF } { \@@_if_match:nn { \@@_build:N #1 } {#2} \@@_return: } +\prg_generate_conditional_variant:Nnn \regex_match:Nn { NV } { T , F , TF } % \end{macrocode} % \end{macro} % -% \begin{macro}{\regex_count:nnN, \regex_count:NnN} +% \begin{macro} +% {\regex_count:nnN, \regex_count:nVN, \regex_count:NnN, \regex_count:NVN} % Again, use an auxiliary whose first argument builds the \textsc{nfa}. % \begin{macrocode} \cs_new_protected:Npn \regex_count:nnN #1 { \@@_count:nnN { \@@_build:n {#1} } } \cs_new_protected:Npn \regex_count:NnN #1 { \@@_count:nnN { \@@_build:N #1 } } +\cs_generate_variant:Nn \regex_count:nnN { nV } +\cs_generate_variant:Nn \regex_count:NnN { NV } % \end{macrocode} % \end{macro} % @@ -6573,11 +6606,16 @@ % % \begin{macro}[noTF] % { -% \regex_extract_once:nnN, \regex_extract_once:NnN, -% \regex_extract_all:nnN, \regex_extract_all:NnN, -% \regex_replace_once:nnN, \regex_replace_once:NnN, -% \regex_replace_all:nnN, \regex_replace_all:NnN, -% \regex_split:nnN, \regex_split:NnN +% \regex_extract_once:nnN, \regex_extract_once:nVN, +% \regex_extract_once:NnN, \regex_extract_once:NVN, +% \regex_extract_all:nnN, \regex_extract_all:nVN, +% \regex_extract_all:NnN, \regex_extract_all:NVN, +% \regex_replace_once:nnN, \regex_replace_once:nVN, +% \regex_replace_once:NnN, \regex_replace_once:NVN, +% \regex_replace_all:nnN, \regex_replace_all:nVN, +% \regex_replace_all:NnN, \regex_replace_all:NVN, +% \regex_split:NnN, \regex_split:NVN, +% \regex_split:nnN, \regex_split:nVN % } % We define here $40$ user functions, following a common pattern in % terms of \texttt{:nnN} auxiliaries, defined in the coming @@ -6595,6 +6633,11 @@ { #1 { \@@_build:n {##1} } {##2} ##3 \@@_return: } \prg_new_protected_conditional:Npnn #3 ##1##2##3 { T , F , TF } { #1 { \@@_build:N ##1 } {##2} ##3 \@@_return: } + \cs_generate_variant:Nn #2 { nV } + \prg_generate_conditional_variant:Nnn #2 { nV } { T , F , TF } + \cs_generate_variant:Nn #3 { NV } + \prg_generate_conditional_variant:Nnn #3 { NV } { T , F , TF } + } \@@_tmp:w \@@_extract_once:nnN \regex_extract_once:nnN \regex_extract_once:NnN |