• <small id='31aeU'></small><noframes id='31aeU'>

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

        Boost C++ regex - 如何获得多个匹配项

        时间:2023-07-20

          <tbody id='HRXvL'></tbody>

      1. <tfoot id='HRXvL'></tfoot>
          <bdo id='HRXvL'></bdo><ul id='HRXvL'></ul>

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

                1. <small id='HRXvL'></small><noframes id='HRXvL'>

                  本文介绍了Boost C++ regex - 如何获得多个匹配项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果我有一个简单的正则表达式模式,比如ab".我有一个字符串,它有多个匹配项,例如abc abd".如果我执行以下操作...

                  If I have a simple regex pattern like "ab." and I have a string that has multiple matches like "abc abd". If I do the following...

                  boost::match_flag_type flags = boost::match_default;
                  boost::cmatch mcMatch;
                  boost::regex_search("abc abd", mcMatch, "ab.", flags)
                  

                  然后 mcMatch 只包含第一个abc"结果.如何获得所有可能的匹配项?

                  Then mcMatch contains just the first "abc" result. How can I get all possible matches?

                  推荐答案

                  你可以使用 boost::sregex_token_iterator 就像这个简短的例子:

                  You can use the boost::sregex_token_iterator like in this short example:

                  #include <boost/regex.hpp>
                  #include <iostream>
                  #include <string>
                  
                  int main() {
                      std::string text("abc abd");
                      boost::regex regex("ab.");
                  
                      boost::sregex_token_iterator iter(text.begin(), text.end(), regex, 0);
                      boost::sregex_token_iterator end;
                  
                      for( ; iter != end; ++iter ) {
                          std::cout<<*iter<<'
                  ';
                      }
                  
                      return 0;
                  }
                  

                  这个程序的输出是:

                  abc
                  abd
                  

                  这篇关于Boost C++ regex - 如何获得多个匹配项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Boost::Spirit::QI 解析器:解析元素的索引 下一篇:boost::spirit::lex &amp; 问题空白

                  相关文章

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

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