字符串的分割

来源:互联网 发布:数据牛牛视频 编辑:程序博客网 时间:2024/05/21 15:53
#include <iostream>
#include <string>
#include <vector>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
   
using namespace std;
   
int main( int argc, char** argv )
{
  string s = "Hello, the beautiful world!";
  vector<string> rs;
  boost::split( rs, s, boost::is_any_of( " ,!" ), boost::token_compress_on );
  for( vector<string>::iterator it = rs.begin(); it != rs.end(); ++ it )
    cout << *it << endl;
   
  return 0;
}
原创粉丝点击