X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Ftests%2Fbiblio.cpp;h=4ba1d40a341fe2754000b12cdbf6122c4da5e2df;hb=394fc5cf15372eee1dbb80828a86c7b97abadeac;hp=933c87ae058205355bc3f0279690ac3af008c5b8;hpb=9c55af4a223ce4db29d643251109e245665344bd;p=lyx.git diff --git a/src/frontends/tests/biblio.cpp b/src/frontends/tests/biblio.cpp index 933c87ae05..4ba1d40a34 100644 --- a/src/frontends/tests/biblio.cpp +++ b/src/frontends/tests/biblio.cpp @@ -15,17 +15,22 @@ 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. - // 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: + return lyx::regex_replace(expr, reg, "\\$&"); +#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: return lyx::regex_replace(expr, reg, "\\\\$&"); +#endif }