This commit is contained in:
Isuru Samarathunga
2025-10-15 09:27:19 +05:30
parent 0f557eb010
commit f742dcfaff
8 changed files with 87 additions and 58 deletions

View File

@ -76,19 +76,20 @@ namespace ia::iae
std::string result;
std::string::const_iterator search_start(text.cbegin());
SIZE_T t1 = 0, t2 = 0;
SIZE_T t = 0;
while (std::regex_search(search_start, text.cend(), match, std::regex(pattern.c_str())))
{
for(SIZE_T i = 1; i < match.size(); i++)
{
result += text.substr(t1, match.position(i) - t1);
result += std::string(groupTransformer(i - 1, match.str(i).c_str()).c_str());
t1 = match.position(i);
t2 = match.str(i).length();
const auto p = match.position(i) + (search_start - text.cbegin());
const auto l = match.length(i);
result += text.substr(t, p - t);
result += groupTransformer(i - 1, text.substr(p, l).c_str()).c_str();
t = p + l;
}
result += text.substr(match.suffix().first - text.begin() - 1);
search_start = match.suffix().first;
search_start = text.cbegin() + t;
}
result += text.substr(t, text.size() - t);
return result.c_str();
}