normalize_statement.cc
Go to the documentation of this file.
2 
3 #include <regex>
4 
5 void
7 {
8  // Remove spaces around commas
9  {
10  std::regex const r{"\\s*,\\s*"};
11  to_replace = std::regex_replace(to_replace, r, ",");
12  }
13  // Remove spaces around parentheses
14  {
15  std::regex const r{R"(\s*([\(\)])\s*)"};
16  to_replace = std::regex_replace(to_replace, r, "$1");
17  }
18  // Replace multiple spaces with 1 space.
19  {
20  std::regex const r{"\\s+"};
21  to_replace = std::regex_replace(to_replace, r, " ");
22  }
23 }
24 
26  std::string to_replace) // Argument is a copy!
27 {
28  normalize_statement(to_replace);
29  return to_replace;
30 }
std::string string
Definition: nybbler.cc:12
void normalize_statement(std::string &to_replace)
std::string normalized_statement(std::string to_replace)