mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-06-06 13:18:57 +08:00
Add str_startswith
This commit is contained in:
@@ -101,6 +101,14 @@ bool str_util::str_endswith(std::string input, std::string pattern) {
|
||||
return i == ilen - plen;
|
||||
}
|
||||
|
||||
bool str_util::str_startswith(std::string input, std::string pattern) {
|
||||
auto ilen = input.length();
|
||||
auto plen = pattern.length();
|
||||
if (ilen < plen) return false;
|
||||
auto i = input.find(pattern);
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
std::string str_util::remove_quote(std::string input) {
|
||||
if (input.length() < 2) return input;
|
||||
if (input[0] == '"' && input[input.length() - 1] == '"') {
|
||||
|
||||
Reference in New Issue
Block a user