19std::string
trim(std::string s) {
20 const auto notSpace = [](
unsigned char c) {
21 return !std::isspace(c);
23 s.erase(s.begin(), std::find_if(s.begin(), s.end(), notSpace));
24 s.erase(std::find_if(s.rbegin(), s.rend(), notSpace).base(), s.end());
30 ch =
static_cast<char>(std::tolower(
static_cast<unsigned char>(ch)));
35 static const std::regex spacesRe(R
"(\s+)");
36 s = std::regex_replace(std::move(s), spacesRe, " ");
37 return trim(std::move(s));
41 std::istringstream iss(s);
42 std::vector<std::string> out;
45 out.push_back(std::move(t));
Declares private string helpers shared across core implementation files.
std::vector< std::string > splitWhitespace(const std::string &s)
Splits a string on ASCII whitespace.
std::string collapseWhitespace(std::string s)
Collapses consecutive whitespace to single spaces and trims the result.
std::string lowerAscii(std::string s)
Converts ASCII letters in a string to lowercase.
std::string trim(std::string s)
Removes leading and trailing ASCII whitespace from a string.