From 570be4760bf81a5236297ab8d4def66207cbd32e Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Thu, 31 Mar 2022 11:39:46 +0200 Subject: [PATCH] FindAdv: Amend a0daf5e5 1.) Completed non backslashed '{' and '}' in regex in non format-search --- src/lyxfind.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 73453cbf2d..35fdd687a8 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -838,13 +838,14 @@ string correctRegex(string t, bool withformat) * and \{, \}, \[, \] => {, }, [, ] */ string s(""); - regex wordre("(\\\\)*(\\\\(([A-Za-z]+)( |\\{\\})?|[\\[\\]\\{\\}]))"); + regex wordre("(\\\\)*(\\\\(([A-Za-z]+|[\\{\\}])( |\\{\\})?|[\\[\\]\\{\\}]))"); size_t lastpos = 0; smatch sub; bool backslashed = false; if (accents.empty()) buildAccentsMap(); + //LYXERR0("correctRegex input '" << t << "'"); for (sregex_iterator it(t.begin(), t.end(), wordre), end; it != end; ++it) { sub = *it; string replace; @@ -856,7 +857,6 @@ string correctRegex(string t, bool withformat) replace = "\\"; { // transforms '\backslash \{' into '\{' - // and '\{' into '{' string next = t.substr(sub.position(2) + sub.str(2).length(), 2); if ((next == "\\{") || (next == "\\}")) { replace = ""; @@ -889,6 +889,10 @@ string correctRegex(string t, bool withformat) } } } + else if (sub.str(4) == "{") // transforms '\{' into '{' + replace = "{"; + else if (sub.str(4) == "}") + replace = "}"; else { AccentsIterator it_ac = accents.find(sub.str(4)); if (it_ac == accents.end()) { @@ -908,6 +912,7 @@ string correctRegex(string t, bool withformat) return t; else if (lastpos < t.length()) s += t.substr(lastpos, t.length() - lastpos); + //LYXERR0("correctRegex output '" << s << "'"); return s; }