• <tfoot id='mLdJv'></tfoot>

      <i id='mLdJv'><tr id='mLdJv'><dt id='mLdJv'><q id='mLdJv'><span id='mLdJv'><b id='mLdJv'><form id='mLdJv'><ins id='mLdJv'></ins><ul id='mLdJv'></ul><sub id='mLdJv'></sub></form><legend id='mLdJv'></legend><bdo id='mLdJv'><pre id='mLdJv'><center id='mLdJv'></center></pre></bdo></b><th id='mLdJv'></th></span></q></dt></tr></i><div id='mLdJv'><tfoot id='mLdJv'></tfoot><dl id='mLdJv'><fieldset id='mLdJv'></fieldset></dl></div>

      <small id='mLdJv'></small><noframes id='mLdJv'>

        <bdo id='mLdJv'></bdo><ul id='mLdJv'></ul>

      1. <legend id='mLdJv'><style id='mLdJv'><dir id='mLdJv'><q id='mLdJv'></q></dir></style></legend>
      2. 使用 C++11 拆分字符串

        Split a string using C++11(使用 C++11 拆分字符串)

      3. <tfoot id='QAH4j'></tfoot>

        <small id='QAH4j'></small><noframes id='QAH4j'>

          <legend id='QAH4j'><style id='QAH4j'><dir id='QAH4j'><q id='QAH4j'></q></dir></style></legend>
        1. <i id='QAH4j'><tr id='QAH4j'><dt id='QAH4j'><q id='QAH4j'><span id='QAH4j'><b id='QAH4j'><form id='QAH4j'><ins id='QAH4j'></ins><ul id='QAH4j'></ul><sub id='QAH4j'></sub></form><legend id='QAH4j'></legend><bdo id='QAH4j'><pre id='QAH4j'><center id='QAH4j'></center></pre></bdo></b><th id='QAH4j'></th></span></q></dt></tr></i><div id='QAH4j'><tfoot id='QAH4j'></tfoot><dl id='QAH4j'><fieldset id='QAH4j'></fieldset></dl></div>

            <bdo id='QAH4j'></bdo><ul id='QAH4j'></ul>

              <tbody id='QAH4j'></tbody>
                  本文介绍了使用 C++11 拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 C++11 拆分字符串的最简单方法是什么?

                  What would be easiest method to split a string using c++11?

                  我看过这篇帖子所使用的方法,但我觉得使用新标准应该有一种不那么冗长的方法.

                  I've seen the method used by this post, but I feel that there ought to be a less verbose way of doing it using the new standard.

                  我想要一个 vector 作为结果并且能够分隔单个字符.

                  I would like to have a vector<string> as a result and be able to delimitate on a single character.

                  推荐答案

                  std::regex_token_iterator 基于正则表达式执行通用标记化.对单个字符进行简单拆分可能会也可能不会过度,但它有效并且不太冗长:

                  std::regex_token_iterator performs generic tokenization based on a regex. It may or may not be overkill for doing simple splitting on a single character, but it works and is not too verbose:

                  std::vector<std::string> split(const string& input, const string& regex) {
                      // passing -1 as the submatch index parameter performs splitting
                      std::regex re(regex);
                      std::sregex_token_iterator
                          first{input.begin(), input.end(), re, -1},
                          last;
                      return {first, last};
                  }
                  

                  这篇关于使用 C++11 拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)
                      <i id='VCKKU'><tr id='VCKKU'><dt id='VCKKU'><q id='VCKKU'><span id='VCKKU'><b id='VCKKU'><form id='VCKKU'><ins id='VCKKU'></ins><ul id='VCKKU'></ul><sub id='VCKKU'></sub></form><legend id='VCKKU'></legend><bdo id='VCKKU'><pre id='VCKKU'><center id='VCKKU'></center></pre></bdo></b><th id='VCKKU'></th></span></q></dt></tr></i><div id='VCKKU'><tfoot id='VCKKU'></tfoot><dl id='VCKKU'><fieldset id='VCKKU'></fieldset></dl></div>

                        <tfoot id='VCKKU'></tfoot>
                          <bdo id='VCKKU'></bdo><ul id='VCKKU'></ul>

                          <small id='VCKKU'></small><noframes id='VCKKU'>

                              <tbody id='VCKKU'></tbody>

                            <legend id='VCKKU'><style id='VCKKU'><dir id='VCKKU'><q id='VCKKU'></q></dir></style></legend>