21 return trim(str,
" \r\n\t");
25 std::string::size_type pos = str->find_last_not_of(drop);
26 if (pos != std::string::npos) {
28 pos = str->find_first_not_of(drop);
29 if (pos != std::string::npos) str->erase(0, pos);
32 str->erase(str->begin(), str->end());
38 std::string::size_type pos = str->find_last_not_of(drop);
39 if (pos != std::string::npos) {
41 pos = str->find_first_not_of(drop);
42 if (pos != std::string::npos) str->erase(0, pos);
45 str->erase(str->begin(), str->end());
51 return trim(str,
" \r\n\t");
56 std::string::size_type pos1 = str.find_first_not_of(drop);
57 if (pos1 == std::string::npos)
return std::string();
60 std::string out = str.substr(pos1, std::string::npos);
63 std::string::size_type pos2 = out.find_last_not_of(drop);
64 if (pos2 != std::string::npos)
73 out.reserve(str.size());
76 std::string::const_iterator it = str.begin();
77 while (it != str.end() && drop.find(*it) != std::string::npos)
81 out.resize(str.end() - it);
82 std::copy(it, str.end(), out.begin());
85 std::string::size_type pos = out.find_last_not_of(drop);
86 if (pos != std::string::npos)
99 str->erase(str->find_last_not_of(drop) + 1, std::string::npos);
104 str->erase(str->find_last_not_of(drop) + 1, std::string::npos);
113 std::string::size_type pos = str.find_last_not_of(drop);
114 if (pos == std::string::npos)
return std::string();
116 return str.substr(0, pos + 1);
120 std::string::size_type pos = str.find_last_not_of(drop);
121 if (pos == std::string::npos)
return std::string();
123 return str.substr(0, pos + 1);
133 str->erase(0, str->find_first_not_of(drop));
138 str->erase(0, str->find_first_not_of(drop));
147 std::string::size_type pos = str.find_first_not_of(drop);
148 if (pos == std::string::npos)
return std::string();
150 return str.substr(pos, std::string::npos);
154 std::string::size_type pos = str.find_first_not_of(drop);
155 if (pos == std::string::npos)
return std::string();
157 return str.substr(pos, std::string::npos);
std::string & trim(std::string *str)
Trims the given string in-place on the left and right.
std::string & trim_right(std::string *str)
Trims the given string in-place only on the right.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
std::string & trim_left(std::string *str)
Trims the given string in-place only on the left.