设为首页 加入收藏

TOP

C++ 使用正则表达式分割字符串
2014-11-24 14:06:07 来源: 作者: 【 】 浏览:2
Tags:使用 正则 表达式 分割 字符串

#include
#include
#include


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';
}


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Perl切割日志的利器 下一篇C++随机打乱数组

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: