Merge pull request #3331 from Eisfunke/eisfunke/regex-collection-replace

Enable using capture groups in window-rewrite
This commit is contained in:
Alexis Rouillard
2024-06-12 23:02:52 +02:00
committed by GitHub
4 changed files with 8 additions and 5 deletions

View File

@ -31,11 +31,12 @@ RegexCollection::RegexCollection(const Json::Value& map, std::string default_rep
std::sort(rules.begin(), rules.end(), [](Rule& a, Rule& b) { return a.priority > b.priority; });
}
std::string& RegexCollection::find_match(std::string& value, bool& matched_any) {
std::string RegexCollection::find_match(std::string& value, bool& matched_any) {
for (auto& rule : rules) {
if (std::regex_search(value, rule.rule)) {
std::smatch match;
if (std::regex_search(value, match, rule.rule)) {
matched_any = true;
return rule.repr;
return match.format(rule.repr.data());
}
}