Fix InsetListings::getCaption() for std::regex

Back references in the format string of regex_replace use the syntax $n both
in std::regex and in boost::regex for the default format. Boost seems to
support the syntax \n in addition, but it is not documented at
http://www.boost.org/doc/libs/master/libs/regex/doc/html/boost_regex/format.html.
Therefore it is a good idea to use $n also for boost.
This commit is contained in:
Georg Baum 2015-11-22 17:43:10 +01:00
parent 3b842d5a62
commit dfe3a7d9fc
2 changed files with 2 additions and 2 deletions

View File

@ -418,7 +418,7 @@ docstring InsetListings::getCaption(OutputParams const & runparams) const
// //
// NOTE that } is not allowed in blah2. // NOTE that } is not allowed in blah2.
regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)"); regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)");
string const new_cap("\\1\\3},label={\\2"); string const new_cap("$1$3},label={$2");
return from_utf8(regex_replace(to_utf8(cap), reg, new_cap)); return from_utf8(regex_replace(to_utf8(cap), reg, new_cap));
} }

View File

@ -23,7 +23,7 @@ string test_ListingsCaption(string const & cap)
// //
// NOTE that } is not allowed in blah2. // NOTE that } is not allowed in blah2.
regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)"); regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)");
string const new_cap("\\1\\3},label={\\2"); string const new_cap("$1$3},label={$2");
return regex_replace(cap, reg, new_cap); return regex_replace(cap, reg, new_cap);
} }