[LyX/master] FindAdv: Convert '\%' in a regex to '%'

Kornel Benko kornel at lyx.org
Sat Apr 16 12:40:24 UTC 2022


commit 28b206665fb7a90d0998f927cec003fcef9c573e
Author: Kornel Benko <kornel at lyx.org>
Date:   Sat Apr 16 15:10:33 2022 +0200

    FindAdv: Convert '\%' in a regex to '%'
    
    Regex contents comes from handling hullRegexp, so we
    have to reverse some its handling, among others also for the char '%'
---
 src/lyxfind.cpp |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 015e437..2ea1e88 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -838,7 +838,7 @@ 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;
@@ -893,6 +893,8 @@ string correctRegex(string t, bool withformat)
 				replace = "{";
 			else if (sub.str(4) == "}")
 				replace = "}";
+			else if (sub.str(4) == "%")
+				replace = "%";
 			else {
 				AccentsIterator it_ac = accents.find(sub.str(4));
 				if (it_ac == accents.end()) {


More information about the lyx-cvs mailing list