commit dbce5cafcc16706a9d6b7e283daf3ac5bee487fb
Author: Guillaume Munch <[email protected]>
Date: Mon Nov 16 22:40:52 2015 +0000
Rewrite regexes in ECMAScript style (bug #9799)
diff --git a/src/frontends/qt4/GuiCitation.cpp
b/src/frontends/qt4/GuiCitation.cpp
index 052d700..dc41fbd 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 933c87a..5a7a376 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 f8ce18d..a3bf82d 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\": "