mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-06-06 05:08:45 +08:00
Add new function
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user