string_replace_re added

This commit is contained in:
2021-10-24 11:23:44 +02:00
parent 4359012190
commit 79377476cb
5 changed files with 25 additions and 1 deletions

View File

@@ -11,6 +11,12 @@ void replace_substring(std::string &src, const std::string &substr, const std::s
}
}
// Return string where substring regex is replaced with a replacement regex
std::string replace_substring_regexp(const std::string &src, const std::string &substr, const std::string &replacement) {
std::regex e{substr};
return std::regex_replace(src, e, replacement);
}
// Returns true if where contains regex
bool regexp_search(const std::string &where, const std::string &regex_str) {
@@ -101,4 +107,4 @@ size_t string_find_substr(const std::string & str, const std::string & pattern,
size_t p = str.find(pattern, pos);
return p != str.npos ? p : -1;
}
}