[latex3-commits] [git/LaTeX3-latex3-latex3] gh433-regex-case: Name as 'match_case'/'replace_case' (55a068ee7)
Joseph Wright
joseph.wright at morningstar2.co.uk
Mon Jan 10 18:31:37 CET 2022
Repository : https://github.com/latex3/latex3
On branch : gh433-regex-case
Link : https://github.com/latex3/latex3/commit/55a068ee736576e0a40364292bfcea19667db704
>---------------------------------------------------------------
commit 55a068ee736576e0a40364292bfcea19667db704
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Mon Jan 10 17:10:23 2022 +0000
Name as 'match_case'/'replace_case'
>---------------------------------------------------------------
55a068ee736576e0a40364292bfcea19667db704
l3kernel/l3regex.dtx | 86 +++++++++++++++++++--------------------
l3kernel/testfiles/m3regex012.lvt | 34 ++++++++--------
l3kernel/testfiles/m3regex012.tlg | 18 ++++----
3 files changed, 69 insertions(+), 69 deletions(-)
diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index acb7a8a12..293ed4e82 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -620,9 +620,9 @@
% results in \cs[no-index]{l_foo_int} taking the value $5$.
% \end{function}
%
-% \begin{function}[noTF, added = 2021-05-15]{\regex_case_match:nn}
+% \begin{function}[noTF, added = 2022-01-10]{\regex_match_case:nn}
% \begin{syntax}
-% \cs{regex_case_match:nnTF}
+% \cs{regex_match_case:nnTF}
% ~~|{| \\
% ~~~~\Arg{regex_1} \Arg{code case_1} \\
% ~~~~\Arg{regex_2} \Arg{code case_2} \\
@@ -766,9 +766,9 @@
% locally to \meta{tl~var}.
% \end{function}
%
-% \begin{function}[noTF, added = 2021-05-15]{\regex_case_replace_once:nN}
+% \begin{function}[noTF, added = 2022-01-10]{\regex_replace_case_once:nN}
% \begin{syntax}
-% \cs{regex_case_replace_once:nNTF}
+% \cs{regex_replace_case_once:nNTF}
% ~~|{| \\
% ~~~~\Arg{regex_1} \Arg{replacement_1} \\
% ~~~~\Arg{regex_2} \Arg{replacement_2} \\
@@ -790,13 +790,13 @@
% of the \meta{regex} is searched in turn. If one of them matches
% then it is replaced by the corresponding \meta{replacement} as
% described for \cs{regex_replace_once:nnN}. This is equivalent to
-% checking with \cs{regex_case_match:nn} which \meta{regex} matches,
+% checking with \cs{regex_match_case:nn} which \meta{regex} matches,
% then performing the replacement with \cs{regex_replace_once:nnN}.
% \end{function}
%
-% \begin{function}[noTF, added = 2021-05-15]{\regex_case_replace_all:nN}
+% \begin{function}[noTF, added = 2022-01-10]{\regex_replace_case_all:nN}
% \begin{syntax}
-% \cs{regex_case_replace_all:nNTF}
+% \cs{regex_replace_case_all:nNTF}
% ~~|{| \\
% ~~~~\Arg{regex_1} \Arg{replacement_1} \\
% ~~~~\Arg{regex_2} \Arg{replacement_2} \\
@@ -819,7 +819,7 @@
% replacement). For instance
% \begin{verbatim}
% \tl_set:Nn \l_tmpa_tl { Hello,~world! }
-% \regex_case_replace_all:nN
+% \regex_replace_case_all:nN
% {
% { [A-Za-z]+ } { ``\0'' }
% { \b } { --- }
@@ -831,7 +831,7 @@
% the word-boundary assertion |\b| did not match at the start of words
% because the case |[A-Za-z]+| matched at these positions. To change
% this, one could simply swap the order of the two cases in the
-% argument of \cs{regex_case_replace_all:nN}.
+% argument of \cs{regex_replace_case_all:nN}.
% \end{function}
%
% \section{Scratch regular expressions}
@@ -2468,7 +2468,7 @@
% \begin{macro}{\@@_compile_use:n}
% Use a regex, regardless of whether it is given as a string (in which
% case we need to compile) or as a regex variable. This is used for
-% \cs{regex_case_match:nn} and related functions to allow a mixture of
+% \cs{regex_match_case:nn} and related functions to allow a mixture of
% explicit regex and regex variables.
% \begin{macrocode}
\cs_new_protected:Npn \@@_compile_use:n #1
@@ -4301,7 +4301,7 @@
%
% \begin{variable}{\g_@@_case_int}
% Case number that was successfully matched in
-% \cs{regex_case_match:nn} and related functions.
+% \cs{regex_match_case:nn} and related functions.
% \begin{macrocode}
\int_new:N \g_@@_case_int
% \end{macrocode}
@@ -4309,7 +4309,7 @@
%
% \begin{variable}{\l_@@_case_max_group_int}
% The largest group number appearing in any of the \meta{regex} in the
-% argument of \cs{regex_case_match:nn} and related functions.
+% argument of \cs{regex_match_case:nn} and related functions.
% \begin{macrocode}
\int_new:N \l_@@_case_max_group_int
% \end{macrocode}
@@ -6520,26 +6520,26 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[noTF]{\regex_case_match:nn}
+% \begin{macro}[noTF]{\regex_match_case:nn}
% The auxiliary errors if |#1| has an odd number of items, and
% otherwise it sets \cs{g_@@_case_int} according to which case was
% found (zero if not found). The \texttt{true} branch leaves the
% corresponding code in the input stream.
% \begin{macrocode}
-\cs_new_protected:Npn \regex_case_match:nnTF #1#2#3
+\cs_new_protected:Npn \regex_match_case:nnTF #1#2#3
{
- \@@_case_match:nnTF {#1} {#2}
+ \@@_match_case:nnTF {#1} {#2}
{
\tl_item:nn {#1} { 2 * \g_@@_case_int }
#3
}
}
-\cs_new_protected:Npn \regex_case_match:nn #1#2
- { \regex_case_match:nnTF {#1} {#2} { } { } }
-\cs_new_protected:Npn \regex_case_match:nnT #1#2#3
- { \regex_case_match:nnTF {#1} {#2} {#3} { } }
-\cs_new_protected:Npn \regex_case_match:nnF #1#2
- { \regex_case_match:nnTF {#1} {#2} { } }
+\cs_new_protected:Npn \regex_match_case:nn #1#2
+ { \regex_match_case:nnTF {#1} {#2} { } { } }
+\cs_new_protected:Npn \regex_match_case:nnT #1#2#3
+ { \regex_match_case:nnTF {#1} {#2} {#3} { } }
+\cs_new_protected:Npn \regex_match_case:nnF #1#2
+ { \regex_match_case:nnTF {#1} {#2} { } }
% \end{macrocode}
% \end{macro}
%
@@ -6580,7 +6580,7 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[noTF]{\regex_case_replace_once:nN}
+% \begin{macro}[noTF]{\regex_replace_case_once:nN}
% If the input is bad (odd number of items) then take the false
% branch. Otherwise, use the same auxiliary as
% \cs{regex_replace_once:nnN}, but with more complicated code to build
@@ -6588,12 +6588,12 @@
% \cs{tl_item:nn} is only expanded once we know the value of
% \cs{g_@@_case_int}, namely which case matched.
% \begin{macrocode}
-\cs_new_protected:Npn \regex_case_replace_once:nNTF #1#2
+\cs_new_protected:Npn \regex_replace_case_once:nNTF #1#2
{
\int_if_odd:nTF { \tl_count:n {#1} }
{
\msg_error:nnxxxx { regex } { case-odd }
- { \token_to_str:N \regex_case_replace_once:nN(TF) } { code }
+ { \token_to_str:N \regex_replace_case_once:nN(TF) } { code }
{ \tl_count:n {#1} } { \tl_to_str:n {#1} }
\use_ii:nn
}
@@ -6605,12 +6605,12 @@
\bool_if:NTF \g_@@_success_bool
}
}
-\cs_new_protected:Npn \regex_case_replace_once:nN #1#2
- { \regex_case_replace_once:nNTF {#1} {#2} { } { } }
-\cs_new_protected:Npn \regex_case_replace_once:nNT #1#2#3
- { \regex_case_replace_once:nNTF {#1} {#2} {#3} { } }
-\cs_new_protected:Npn \regex_case_replace_once:nNF #1#2
- { \regex_case_replace_once:nNTF {#1} {#2} { } }
+\cs_new_protected:Npn \regex_replace_case_once:nN #1#2
+ { \regex_replace_case_once:nNTF {#1} {#2} { } { } }
+\cs_new_protected:Npn \regex_replace_case_once:nNT #1#2#3
+ { \regex_replace_case_once:nNTF {#1} {#2} {#3} { } }
+\cs_new_protected:Npn \regex_replace_case_once:nNF #1#2
+ { \regex_replace_case_once:nNTF {#1} {#2} { } }
% \end{macrocode}
% \end{macro}
%
@@ -6620,12 +6620,12 @@
% \cs{regex_replace_all:nnN}, but with more complicated code to build
% the automaton, and to find what replacement text to use.
% \begin{macrocode}
-\cs_new_protected:Npn \regex_case_replace_all:nNTF #1#2
+\cs_new_protected:Npn \regex_replace_case_all:nNTF #1#2
{
\int_if_odd:nTF { \tl_count:n {#1} }
{
\msg_error:nnxxxx { regex } { case-odd }
- { \token_to_str:N \regex_case_replace_all:nN(TF) } { code }
+ { \token_to_str:N \regex_replace_case_all:nN(TF) } { code }
{ \tl_count:n {#1} } { \tl_to_str:n {#1} }
\use_ii:nn
}
@@ -6637,12 +6637,12 @@
\bool_if:NTF \g_@@_success_bool
}
}
-\cs_new_protected:Npn \regex_case_replace_all:nN #1#2
- { \regex_case_replace_all:nNTF {#1} {#2} { } { } }
-\cs_new_protected:Npn \regex_case_replace_all:nNT #1#2#3
- { \regex_case_replace_all:nNTF {#1} {#2} {#3} { } }
-\cs_new_protected:Npn \regex_case_replace_all:nNF #1#2
- { \regex_case_replace_all:nNTF {#1} {#2} { } }
+\cs_new_protected:Npn \regex_replace_case_all:nN #1#2
+ { \regex_replace_case_all:nNTF {#1} {#2} { } { } }
+\cs_new_protected:Npn \regex_replace_case_all:nNT #1#2#3
+ { \regex_replace_case_all:nNTF {#1} {#2} {#3} { } }
+\cs_new_protected:Npn \regex_replace_case_all:nNF #1#2
+ { \regex_replace_case_all:nNTF {#1} {#2} { } }
% \end{macrocode}
% \end{macro}
%
@@ -6775,19 +6775,19 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_case_match:nnTF}
-% \begin{macro}[EXP]{\@@_case_match_aux:nn}
+% \begin{macro}{\@@_match_case:nnTF}
+% \begin{macro}[EXP]{\@@_match_case_aux:nn}
% The code would get badly messed up if the number of items in |#1|
% were not even, so we catch this case, then follow the same code as
% \cs{regex_match:nnTF} but using \cs{@@_case_build:n} and without
% returning a result.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_case_match:nnTF #1#2
+\cs_new_protected:Npn \@@_match_case:nnTF #1#2
{
\int_if_odd:nTF { \tl_count:n {#1} }
{
\msg_error:nnxxxx { regex } { case-odd }
- { \token_to_str:N \regex_case_match:nn(TF) } { code }
+ { \token_to_str:N \regex_match_case:nn(TF) } { code }
{ \tl_count:n {#1} } { \tl_to_str:n {#1} }
\use_ii:nn
}
@@ -6798,7 +6798,7 @@
\bool_if:NTF \g_@@_success_bool
}
}
-\cs_new:Npn \@@_case_match_aux:nn #1#2 { \exp_not:n { {#1} } }
+\cs_new:Npn \@@_match_case_aux:nn #1#2 { \exp_not:n { {#1} } }
% \end{macrocode}
% \end{macro}
% \end{macro}
diff --git a/l3kernel/testfiles/m3regex012.lvt b/l3kernel/testfiles/m3regex012.lvt
index bb6a4e4f5..24b40d0d5 100644
--- a/l3kernel/testfiles/m3regex012.lvt
+++ b/l3kernel/testfiles/m3regex012.lvt
@@ -16,13 +16,13 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\TEST { regex_case_match:nn }
+\TEST { regex_match_case:nn }
{
\regex_set:Nn \l_tmpa_regex { [a-z]bc }
\cs_set_protected:Npn \test:n #1
{
\TYPE{#1:}
- \regex_case_match:nnTF
+ \regex_match_case:nnTF
{
\l_tmpa_regex { \TYPE{abc} }
{ (?i) Y \w } { \TYPE{Y} }
@@ -41,13 +41,13 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\TEST { regex_case_replace_once:nN }
+\TEST { regex_replace_case_once:nN }
{
\regex_set:Nn \l_tmpa_regex { [a-z]bc }
\cs_set_protected:Npn \test:n #1
{
\tl_set:Nn \l_tmpa_tl {#1}
- \regex_case_replace_once:nNTF
+ \regex_replace_case_once:nNTF
{
\l_tmpa_regex { (abc,\0,\1) } % should complain about \1 but doesn't
{ (?i) Y (\w) } { [Y,\0,\1] }
@@ -68,13 +68,13 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\TEST { regex_case_replace_all:nN }
+\TEST { regex_replace_case_all:nN }
{
\regex_set:Nn \l_tmpa_regex { [a-z]bc }
\cs_set_protected:Npn \test:n #1
{
\tl_set:Nn \l_tmpa_tl {#1}
- \regex_case_replace_all:nNTF
+ \regex_replace_case_all:nNTF
{
\l_tmpa_regex { (abc,\0,\1) }
{ (?i) Y (\w) } { [Y,\0,\1] }
@@ -92,7 +92,7 @@
\test:n { Y abc YYYz }
\test:n { y abcbc }
\tl_set:Nn \l_tmpa_tl { Hello,~world! }
- \regex_case_replace_all:nNTF
+ \regex_replace_case_all:nNTF
{
{ [A-Za-z]+ } { ``\0'' }
{ \b } { --- }
@@ -100,7 +100,7 @@
} \l_tmpa_tl
{ \TYPE { \l_tmpa_tl } } { \ERROR }
\tl_set:Nn \l_tmpa_tl { Hello,~world! }
- \regex_case_replace_all:nNTF
+ \regex_replace_case_all:nNTF
{
{ \b } { --- }
{ [A-Za-z]+ } { ``\0'' }
@@ -108,7 +108,7 @@
} \l_tmpa_tl
{ \TYPE { \l_tmpa_tl } } { \ERROR }
\tl_set:Nn \l_tmpa_tl { a ( b ( c ) d ( ) ) e }
- \regex_case_replace_all:nN
+ \regex_replace_case_all:nN
{
{ \( } { \{ }
{ \) } { \} }
@@ -116,7 +116,7 @@
\l_tmpa_tl
\tl_analysis_log:N \l_tmpa_tl
\tl_set:Nn \l_tmpa_tl { a { } b | { | | } | | e }
- \regex_case_replace_all:nN
+ \regex_replace_case_all:nN
{
{ \| } { \} }
{ . (.) } { \0\1 }
@@ -124,7 +124,7 @@
\l_tmpa_tl
\tl_analysis_log:N \l_tmpa_tl
\tl_clear:N \l_tmpa_tl
- \regex_case_replace_all:nN
+ \regex_replace_case_all:nN
{
{ \A } { A }
\Z { Z }
@@ -137,12 +137,12 @@
\TEST { regex_case ~ errors }
{
- \regex_case_match:nnTF { Something ~ odd. } { .. } { \ERROR } { \FALSE }
- \regex_case_match:nn { * } { .. }
- \regex_case_replace_once:nNTF { Something ~ odd. } \l_tmpa_tl { \ERROR } { \FALSE }
- \regex_case_replace_once:nN { * } { .. }
- \regex_case_replace_all:nNTF { Something ~ odd. } \l_tmpa_tl { \ERROR } { \FALSE }
- \regex_case_replace_all:nN { * } { .. }
+ \regex_match_case:nnTF { Something ~ odd. } { .. } { \ERROR } { \FALSE }
+ \regex_match_case:nn { * } { .. }
+ \regex_replace_case_once:nNTF { Something ~ odd. } \l_tmpa_tl { \ERROR } { \FALSE }
+ \regex_replace_case_once:nN { * } { .. }
+ \regex_replace_case_all:nNTF { Something ~ odd. } \l_tmpa_tl { \ERROR } { \FALSE }
+ \regex_replace_case_all:nN { * } { .. }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/l3kernel/testfiles/m3regex012.tlg b/l3kernel/testfiles/m3regex012.tlg
index 47c49cede..529fef002 100644
--- a/l3kernel/testfiles/m3regex012.tlg
+++ b/l3kernel/testfiles/m3regex012.tlg
@@ -2,7 +2,7 @@ This is a generated file for the LaTeX (2e + expl3) validation system.
Don't change this file in any respect.
Author: Bruno Le Floch
============================================================
-TEST 1: regex_case_match:nn
+TEST 1: regex_match_case:nn
============================================================
:
FALSE
@@ -25,7 +25,7 @@ Z
TRUE
============================================================
============================================================
-TEST 2: regex_case_replace_once:nN
+TEST 2: regex_replace_case_once:nN
============================================================
: FALSE
abc => (abc,abc,)
@@ -36,7 +36,7 @@ y;bc: FALSE
y;bcz => y;bc<z,zZ>
============================================================
============================================================
-TEST 3: regex_case_replace_all:nN
+TEST 3: regex_replace_case_all:nN
============================================================
: FALSE
ybc => (abc,ybc,)
@@ -90,40 +90,40 @@ A
============================================================
TEST 4: regex_case errors
============================================================
-! LaTeX3 Error: \regex_case_match:nn(TF) with odd number of items
+! LaTeX3 Error: \regex_match_case:nn(TF) with odd number of items
For immediate help type H <return>.
...
l. ... }
There must be a code part for each regex: found odd number of items (13) in
Something odd.
FALSE
-! LaTeX3 Error: \regex_case_match:nn(TF) with odd number of items
+! LaTeX3 Error: \regex_match_case:nn(TF) with odd number of items
For immediate help type H <return>.
...
l. ... }
There must be a code part for each regex: found odd number of items (1) in
*
-! LaTeX3 Error: \regex_case_replace_once:nN(TF) with odd number of items
+! LaTeX3 Error: \regex_replace_case_once:nN(TF) with odd number of items
For immediate help type H <return>.
...
l. ... }
There must be a code part for each regex: found odd number of items (13) in
Something odd.
FALSE
-! LaTeX3 Error: \regex_case_replace_once:nN(TF) with odd number of items
+! LaTeX3 Error: \regex_replace_case_once:nN(TF) with odd number of items
For immediate help type H <return>.
...
l. ... }
There must be a code part for each regex: found odd number of items (1) in
*
-! LaTeX3 Error: \regex_case_replace_all:nN(TF) with odd number of items
+! LaTeX3 Error: \regex_replace_case_all:nN(TF) with odd number of items
For immediate help type H <return>.
...
l. ... }
There must be a code part for each regex: found odd number of items (13) in
Something odd.
FALSE
-! LaTeX3 Error: \regex_case_replace_all:nN(TF) with odd number of items
+! LaTeX3 Error: \regex_replace_case_all:nN(TF) with odd number of items
For immediate help type H <return>.
...
l. ... }
More information about the latex3-commits
mailing list.