]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiCitation.cpp
Fix C++11 std::regex incompatibility
[features.git] / src / frontends / qt4 / GuiCitation.cpp
index dc41fbdc871828da61c9eacc865e490ddb2cdc0d..8856ebc8668473a79e65e6587beda75254ab8e64 100644 (file)
@@ -670,11 +670,19 @@ static docstring escape_special_chars(docstring const & expr)
 
        // $& 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.
-       // Thus, to prefix a matched expression with '\', we use:
+#if defined(LYX_USE_CXX11) && defined(LYX_USE_STD_REGEX)
+       // To prefix a matched expression with a single literal backslash, we
+       // need to escape it for the C++ compiler and use:
+       // FIXME: UNICODE
+       return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\$&")));
+#else
+       // A backslash in the format string starts an escape sequence in boost.
+       // Thus, to prefix a matched expression with a single literal backslash,
+       // we need to give two backslashes to the regex engine, and escape both
+       // for the C++ compiler and use:
        // FIXME: UNICODE
        return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\\\$&")));
+#endif
 }