rooney
C++ 使用正则表达式分割字符串

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

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-21
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2022-01-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案