Fix Regex::replace_all to actually do something

This commit is contained in:
Twan van Laarhoven
2020-04-20 21:18:40 +02:00
parent a5b2b77d2a
commit b0180547ae
3 changed files with 4 additions and 7 deletions
+1 -2
View File
@@ -128,8 +128,7 @@ SCRIPT_FUNCTION_WITH_SIMPLIFY(replace) {
SCRIPT_RETURN(replacer.apply(ctx, input));
} else {
// simple replacing
replacer.match->replace_all(&input, replacer.replacement_string);
SCRIPT_RETURN(input);
SCRIPT_RETURN(replacer.match->replace_all(input, replacer.replacement_string));
}
}
SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(replace) {
+2 -4
View File
@@ -24,10 +24,8 @@ void Regex::assign(const String& code) {
}
}
void Regex::replace_all(String* input, const String& format) {
wxStdString std_string = toStdString(*input);
regex_replace(std_string, regex, toStdString(format), boost::format_sed);
*input = std_string;
String Regex::replace_all(const String& input, const String& format) const {
return regex_replace(toStdString(input), regex, toStdString(format), boost::format_sed);
}
#else // USE_BOOST_REGEX
+1 -1
View File
@@ -85,7 +85,7 @@
inline bool matches(Results& results, const String::const_iterator& begin, const String::const_iterator& end) const {
return regex_search(begin, end, results, regex);
}
void replace_all(String* input, const String& format);
String replace_all(const String& input, const String& format) const;
inline bool empty() const {
return regex.empty();