现在的位置: 首页 > 综合 > 正文

trim函数,剔除字符

2011年08月30日 ⁄ 综合 ⁄ 共 368字 ⁄ 字号 评论关闭

* Remove surrounding whitespace from a std::string.

* @param s The string to be modified.

* @param t The set of characters to delete from each end

* of the string.

* @return The same string passed in as a parameter reference.

*/

std::string& trim(std::string& s, const char* t = " \t\n\r\f\v")

{

s.erase(0, s.find_first_not_of(t));

s.erase(s.find_last_not_of(t) + 1);

return s;

}

原文:

http://www.cplusplus.com/forum/beginner/50209/

抱歉!评论已关闭.