This commit is contained in:
2024-01-07 10:58:30 +08:00
parent 2515ccdb54
commit 4a75daa77d
4 changed files with 171 additions and 14 deletions

View File

@@ -99,3 +99,13 @@ std::string str_util::remove_quote(std::string input) {
return input;
}
}
std::string str_util::str_trim(std::string input) {
while (!input.empty() && (input.front() == ' ' || input.front() == '\t' || input.front() == '\r' || input.front() == '\n')) {
input.erase(input.begin());
}
while (!input.empty() && (input.back() == ' ' || input.back() == '\t' || input.back() == '\r' || input.back() == '\n')) {
input.erase(input.end() - 1);
}
return input;
}