• <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 拆分字符串

        时间:2023-08-26

      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 拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:架构 i386 的未定义符号: 下一篇:C++ - 反复使用 istringstream

                  相关文章

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

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