示例:
string value = "\"12\"\r\n\"34\"\r\n"; //字符串为:
"12"
"34"
通过以下函数作用:
boost::algorithm::trim_if(value, boost::algorithm::is_any_of("\n\r\""));
得到结果为:
12"\r\n"34
即,把value两边的引号、回车、换行符去掉了,而value中间出现的引号、回车、换行符不会去掉。
本文介绍了一种使用Boost算法库中的trim_if函数去除字符串两端特定字符的方法,该方法可以有效移除字符串开头和结尾处的引号、回车及换行符等,而不影响字符串中间内容。
示例:
string value = "\"12\"\r\n\"34\"\r\n"; //字符串为:
"12"
"34"
通过以下函数作用:
boost::algorithm::trim_if(value, boost::algorithm::is_any_of("\n\r\""));
得到结果为:
12"\r\n"34
即,把value两边的引号、回车、换行符去掉了,而value中间出现的引号、回车、换行符不会去掉。
转载于:https://my.oschina.net/zmlblog/blog/131104
248
951
181

被折叠的 条评论
为什么被折叠?