C++学习:去掉字符串的首尾指定字符
2016-09-10 16:25
363 查看
注意是去掉strDrop中包含的所有字符。
template<typename StrType> inline StrType BinaryDecisionTree::LeftTrimString(const StrType& strSource, const StrType& strDrop) { StrType strDstString(strSource); return strDstString.erase(0, strDstString.find_first_not_of(strDrop)); } template<typename StrType> inline StrType BinaryDecisionTree::RightTrimString(const StrType& strSource, const StrType& strDrop) { StrType strDstString(strSource); return strDstString.erase(strDstString.find_last_not_of(strDrop) + 1); } template<typename StrType> inline StrType BinaryDecisionTree::TrimString(const StrType& strSource, const StrType& strDrop) { return LeftTrimString(RightTrimString(strSource, strDrop), strDrop); }
相关文章推荐
- C++ 去掉字符串首尾的 \x20 \r \n 字符
- 《Windows Via C/C++》边学习,边翻译(五)操作字符和字符串-4
- 将用户输入的字符串转换为可换行、替换Html编码、无危害数据库特殊字符、去掉首尾空白、的安全方便代码
- 去掉字符串中的指定字符
- C++去掉字符串中首尾空格和所有空格
- C/C++学习笔记笔记28:字符与字符串
- 《Windows Via C/C++》边学习,边翻译(六)操作字符和字符串-5
- C/C++去除字符串首尾空白字符
- 学习C/C++语言:字符数组的使用,统计字符串中单词个数
- C#去掉字符串头尾指定字符
- python3.4学习笔记(二十二) python 在字符串里面插入指定分割符,将list中的字符转为数字
- C++中使用指定字符分割字符串
- C/C++/VC 获取指定字符在字符串中的出现次数
- oracle去掉字符串中所有指定字符
- 《Windows Via C/C++》边学习,边翻译(三)操作字符和字符串-2
- C#去掉字符串头尾指定字符
- C/C++ 去掉字符串首尾空格函数
- C/C++ 去掉字符串首尾空格函数
- C/C++学习笔记32:字符串操作与字符子串问题
- 【C++编程技巧】根据字符串中的指定字符作为分界将字符串拆分