23 auto pred=[](
char c){
return std::isspace(c); };
25 std::string::const_iterator left
26 =std::find_if_not(s.begin(), s.end(), pred);
32 std::string::const_reverse_iterator right
33 =std::find_if_not(s.rbegin(), s.rend(), pred);
36 return s.substr(i, (j-i+1));
52 std::vector<std::string> &result,
67 INVARIANT(n > 0,
"Empty string case should already be handled");
76 std::string new_s=s.substr(start, i-start);
81 if(!remove_empty || !new_s.empty())
82 result.push_back(new_s);
88 std::string new_s=s.substr(start, n-start);
93 if(!remove_empty || !new_s.empty())
94 result.push_back(new_s);
101 const std::string &s,
110 std::vector<std::string> result;
113 if(result.size() != 2)
116 "' to contain two substrings "
118 delim +
" but has " +
127 const std::string &s,
132 std::vector<std::string> result;
138 const std::string &s,
141 std::string result=
"";
142 const size_t index=s.find_last_of(delim);
143 if(index!=std::string::npos)
144 result=s.substr(0, index);
152 for(std::size_t i=0; i<s.size(); i++)
154 if(s[i]==
'\\' || s[i]==
'"')
173 const std::string &from,
174 const std::string &to)
176 size_t start_pos = 0;
177 while((start_pos = str.find(from, start_pos)) != std::string::npos)
179 str.replace(start_pos, from.length(), to);
180 start_pos += to.length();