feat add StartsWith,EndsWith
This commit is contained in:
@@ -65,4 +65,18 @@ TrimRight(const std::string &str, const std::string &chars)
|
||||
return str.substr(0, end);
|
||||
}
|
||||
|
||||
bool
|
||||
EndsWith(const std::string &str, const std::string &suffix)
|
||||
{
|
||||
return str.size() >= suffix.size()
|
||||
&& str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
|
||||
}
|
||||
|
||||
bool
|
||||
StartsWith(const std::string &str, const std::string &prefix)
|
||||
{
|
||||
return str.size() >= prefix.size()
|
||||
&& str.compare(0, prefix.size(), prefix) == 0;
|
||||
}
|
||||
|
||||
}// namespace sled
|
||||
|
Reference in New Issue
Block a user