Refactor Regex classes further

This commit changes Regex interface rather dramatically.

Most importantly, RegexMatch class now contains a list of matched groups,
with group(0) being entire match, group(1) - first capturing group,
and so on.

Secondly, searchAll now returns a list of RegexMatch objects instead
of reversed flattened list of groups from all matches.
This commit is contained in:
WGH
2019-01-29 21:29:44 +03:00
committed by Felipe Zimmerle
parent a2dc896520
commit 55b81f0e10
12 changed files with 167 additions and 159 deletions

View File

@@ -64,18 +64,16 @@ void json2bin(std::string *str) {
while (re.search(*str, &match)) {
unsigned int p;
std::string toBeReplaced = match.str();
toBeReplaced.erase(0, 2);
sscanf(toBeReplaced.c_str(), "%x", &p);
replaceAll(str, match.str(), p);
std::string toBeReplaced = match.group(0).string;
sscanf(toBeReplaced.substr(2).c_str(), "%x", &p);
replaceAll(str, toBeReplaced, p);
}
while (re2.search(*str, &match)) {
unsigned int p;
std::string toBeReplaced = match.str();
toBeReplaced.erase(0, 2);
sscanf(toBeReplaced.c_str(), "%4x", &p);
replaceAll(str, match.str(), p);
std::string toBeReplaced = match.group(0).string;
sscanf(toBeReplaced.substr(2).c_str(), "%4x", &p);
replaceAll(str, toBeReplaced, p);
}
/*