Add new function

This commit is contained in:
2024-01-05 22:54:34 +08:00
parent 63992e1238
commit 117f6b335c
2 changed files with 15 additions and 0 deletions

View File

@@ -57,3 +57,11 @@ std::string str_util::str_hex(std::string input) {
}
return output;
}
bool str_util::str_endswith(std::string input, std::string pattern) {
auto ilen = input.length();
auto plen = pattern.length();
if (ilen < plen) return false;
auto i = input.rfind(pattern);
return i == ilen - plen;
}