c++ 使用正则表达式分割字符串
2011-09-18 16:53
525 查看
#include <iostream>
#include <string>
#include <boost/regex.hpp>
int main(){
std::string s = "who,lives:in-a,pineapple under the sea?";
boost::regex re(",|:|-|\\s+");
boost::sregex_token_iterator
p(s.begin(),s.end(),re,-1);
boost::sregex_token_iterator end;
while(p!=end)
std::cout<<*p++<<'\n';
}
#include <string>
#include <boost/regex.hpp>
int main(){
std::string s = "who,lives:in-a,pineapple under the sea?";
boost::regex re(",|:|-|\\s+");
boost::sregex_token_iterator
p(s.begin(),s.end(),re,-1);
boost::sregex_token_iterator end;
while(p!=end)
std::cout<<*p++<<'\n';
}
相关文章推荐
- C++ 使用正则表达式分割字符串
- python里使用正则表达式来分割字符串
- Split分割字符串使用方法 例子 部分正则表达式
- 使用正则表达式分割字符串
- 14.05 - 使用正则表达式分割字符串
- android使用正则表达式过滤字符串
- 有关字符串分割的问题(正则表达式)
- PHP中判断字符串是否包含某个字符时,建议使用正则表达式preg_match()
- 使用js正则表达式分割内容分别显示
- C++ regex 正则表达式的使用
- 使用正则表达式和replace替换一个字符串中截取的一字符串
- C++中的也能使用正则表达式
- 使用正则表达式找出不包含特定字符串的条目(?!否定前瞻解析)
- C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
- C# 使用正则表达式去掉字符串中的数字
- C++正则表达式使用
- 用正则表达式分割字符串
- java 使用正则表达式统计一个字符串中子字符串出现次数
- 使用正则表达式,去除C++的注释