From 0befab300849be7ac0f77bc4228f8de50a108191 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 25 Oct 2024 18:35:43 +0200 Subject: Make regex_replace_search() not to match empty substrings in non-empty strings --- tests/regex/testscript | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/regex/testscript b/tests/regex/testscript index 93ad4b6..137469d 100644 --- a/tests/regex/testscript +++ b/tests/regex/testscript @@ -63,6 +63,21 @@ : $* xay '/a/\lVZ/' >xvZy } + + : empty-substring + : + : Note that the regex search-based replacement with the match_not_null flag + : is broken for older versions of libstdc++ and libc++ (may ignore + : match_not_null for the former and may hang for some string/pattern for the + : latter). + : + if (($cxx.id != 'gcc' || $cxx.version.major >= 7) && \ + ($cxx.id != 'clang' || $cxx.version.major >= 6)) + { + $* '' '/.*/x/' >'x' : empty + $* a '/a*/x/' >'x' : match + $* aa '/b*/x/' == 1 : no-match + } } : replace-match @@ -72,6 +87,14 @@ $* abc '/a(b)c/x\1y/' >xby : match $* abcd '/a(b)c/x\1yd/' == 1 : no-match + + : empty-substring + : + { + $* '' '/.*/x/' >'x' : empty + $* a '/a*/x/' >'x' : match + $* ab '/a(c*)(b)/\1\2/' >'b' : match-mid + } } : invalid-regex-fmt -- cgit v1.1