From http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
| 20 | |
| 21 | // From http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring |
| 22 | inline std::string trim(const std::string &s) |
| 23 | { |
| 24 | auto wsfront=std::find_if_not(s.begin(),s.end(),[](int c){return std::isspace(c);}); |
| 25 | auto wsback=std::find_if_not(s.rbegin(),s.rend(),[](int c){return std::isspace(c);}).base(); |
| 26 | return (wsback<=wsfront ? std::string() : std::string(wsfront,wsback)); |
| 27 | } |
| 28 | |
| 29 | inline bool contains(const std::string& string, const std::string& search) |
| 30 | { |