网上找了下std::string的trim()实现,都不是很满意。自己写了一个,记录一下。
inline static string& trim(string& text)
{
if(!text.empty())
{
text.erase(0, text.find_first_not_of(_T(" \n\r\t")));
text.erase(text.find_last_not_of(_T(" \n\r\t")) + 1);
}
return text;
}