//: trim.cpp : Zeichen an Anfang/Ende eines string entfernen - R.Richter 2011-05-22 /////////////////////////////////////////////////////////////////////////////////// #include std::string rtrim(std::string s, std::string const& delim = " \t\r\n") { std::string::size_type last = s.find_last_not_of(delim.c_str()); return last == std::string::npos ? "" : s.erase(last + 1); } std::string ltrim(std::string s, std::string const& delim = " \t\r\n") { return s.erase(0, s.find_first_not_of(delim.c_str())); } std::string trim(std::string s, std::string const& delim = " \t\r\n") { return ltrim(rtrim(s, delim), delim); }