logo
  • 教程列表
  • SO官方文档
  • 正则表达式
    • 基本正则表达式匹配和正则表达式搜索示例
    • 正则表达式迭代器示例
    • 锚
    • 正则表达式替换示例
    • 正则表达式令牌迭代器示例
    • 拆分字符串
    • 量词
  1. StackOverflow 文档
  2. C++ 教程
  3. 正则表达式
  4. 拆分字符串

拆分字符串

Created: November-22, 2018

std::vector<std::string> split(const std::string &str, std::string regex)
{
    std::regex r{ regex };
    std::sregex_token_iterator start{ str.begin(), str.end(), r, -1 }, end;
    return std::vector<std::string>(start, end);
}
split("Some  string\t with whitespace ", "\\s+"); // "Some", "string", "with", "whitespace"
  • 量词
  • 正则表达式令牌迭代器示例

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明