string_replace_re added
This commit is contained in:
@@ -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 ®ex_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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user