bool compare_pred(unsigned char a, unsigned char b) {
return std::tolower(a) == std::tolower(b);
}
bool EndsWith(const std::string& str, const std::string& suffix) {
if (str.size() < suffix.size()) {
return false;
}
std::string tstr = str.substr(str.size() - suffix.size());
if (tstr.length() == suffix.length()) {
return std::equal(suffix.begin(), suffix.end(), tstr.begin(), compare_pred);
} else {
return false;
}
}
判断字符串以XX结尾C++
于 2021-07-26 10:10:13 首次发布