From: Guillaume Munch Date: Mon, 16 Nov 2015 22:40:52 +0000 (+0000) Subject: Rewrite regexes in ECMAScript style (bug #9799) X-Git-Tag: 2.2.0alpha2~75 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=dbce5cafcc16706a9d6b7e283daf3ac5bee487fb;p=features.git Rewrite regexes in ECMAScript style (bug #9799) --- diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index 052d700b2b..dc41fbdc87 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -665,12 +665,10 @@ void GuiCitation::filterByEntryType(BiblioInfo const & bi, static docstring escape_special_chars(docstring const & expr) { // Search for all chars '.|*?+(){}[^$]\' - // Note that '[' and '\' must be escaped. - // This is a limitation of lyx::regex, but all other chars in BREs - // are assumed literal. - static const lyx::regex reg("[].|*?+(){}^$\\[\\\\]"); + // Note that '[', ']', and '\' must be escaped. + static const lyx::regex reg("[.|*?+(){}^$\\[\\]\\\\]"); - // $& is a perl-like expression that expands to all + // $& is an ECMAScript format expression that expands to all // of the current match // The '$' must be prefixed with the escape character '\' for // boost to treat it as a literal. diff --git a/src/frontends/tests/biblio.cpp b/src/frontends/tests/biblio.cpp index 933c87ae05..5a7a376d3e 100644 --- a/src/frontends/tests/biblio.cpp +++ b/src/frontends/tests/biblio.cpp @@ -15,12 +15,10 @@ using namespace std; string const escape_special_chars(string const & expr) { // Search for all chars '.|*?+(){}[^$]\' - // Note that '[' and '\' must be escaped. - // This is a limitation of lyx::regex, but all other chars in BREs - // are assumed literal. - lyx::regex reg("[].|*?+(){}^$\\[\\\\]"); + // Note that '[', ']', and '\' must be escaped. + lyx::regex reg("[.|*?+(){}^$\\[\\]\\\\]"); - // $& is a perl-like expression that expands to all + // $& is a ECMAScript format expression that expands to all // of the current match // The '$' must be prefixed with the escape character '\' for // boost to treat it as a literal. diff --git a/src/insets/ExternalTransforms.cpp b/src/insets/ExternalTransforms.cpp index f8ce18d3ec..a3bf82df65 100644 --- a/src/insets/ExternalTransforms.cpp +++ b/src/insets/ExternalTransforms.cpp @@ -283,7 +283,7 @@ string const sanitizeLatexOption(string const & input) // "[,,,,foo..." -> "foo..." ("foo..." may be empty) string output; lyx::smatch what; - static lyx::regex const front("^( *[[],*)(.*)$"); + static lyx::regex const front("^( *\\[,*)(.*)$"); regex_match(it, end, what, front); if (!what[0].matched) { @@ -309,7 +309,7 @@ string const sanitizeLatexOption(string const & input) // Strip any trailing commas // "...foo,,,]" -> "...foo" ("...foo,,," may be empty) - static lyx::regex const back("^(.*[^,])?,*[]] *$"); + static lyx::regex const back("^(.*[^,])?,*\\] *$"); regex_match(output, what, back); if (!what[0].matched) { lyxerr << "Unable to sanitize LaTeX \"Option\": "