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

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

        <tfoot id='jXbGp'></tfoot>

        您可以使用 Boost.Regex 来解析流吗?

        Can you use Boost.Regex to parse a stream?(您可以使用 Boost.Regex 来解析流吗?)
      2. <legend id='aXVmz'><style id='aXVmz'><dir id='aXVmz'><q id='aXVmz'></q></dir></style></legend>

            <tbody id='aXVmz'></tbody>

              <bdo id='aXVmz'></bdo><ul id='aXVmz'></ul>
            • <tfoot id='aXVmz'></tfoot>

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

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

                  本文介绍了您可以使用 Boost.Regex 来解析流吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在玩 Boost.Regex 来解析单词和数字的字符串.这是我目前所拥有的:

                  I was playing around with Boost.Regex to parse strings for words and numbers. This is what I have so far:

                  #include <iostream>
                  #include <string>
                  #include <boost/foreach.hpp>
                  #include <boost/regex.hpp>
                  #include <boost/range.hpp>
                  
                  using namespace std;
                  using namespace boost;
                  
                  int main()
                  {
                      regex re
                      (
                          "("
                              "([a-z]+)|"
                              "(-?[0-9]+(\.[0-9]+)?)"
                          ")"
                      );
                  
                      string s = "here is a	 list of Words. and some 1239.32 numbers to 3323 parse.";
                      sregex_iterator m1(s.begin(), s.end(), re), m2;
                  
                      BOOST_FOREACH (const match_results<string::const_iterator>& what, make_iterator_range(m1, m2)) {
                          cout << ":" << what[1].str() << ":" << what.position(1) << ":" << what.length(1) << endl;
                      }
                  
                      return 0;
                  }
                  

                  有没有办法告诉正则表达式从流而不是字符串中解析?似乎应该可以使用任何迭代器.

                  Is there a way to tell regex to parse from a stream rather than a string? It seems like it should be possible to use any iterator.

                  推荐答案

                  Boost.IOStreams 有一个 regex_filter 允许在流上执行相当于 regex_replace 的操作.然而,从实现来看,它似乎是作弊",因为它只是将整个流加载到缓冲区中,然后在该缓冲区上调用 Boost.Regex.

                  Boost.IOStreams has a regex_filter allowing one to perform the equivalent of a regex_replace on a stream. However, looking at the implementation, it seems to "cheat" in that it simply loads the whole stream into a buffer and then calls Boost.Regex on that buffer.

                  可以使用部分匹配" 支持 Boost.Regex.查看页面末尾的示例.

                  Making a regex search on a stream's contents without having to entirely load it in memory can be done with the "partial match" support of Boost.Regex. Look at the example at the end of the page.

                  这篇关于您可以使用 Boost.Regex 来解析流吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                  How should a size-limited stl-like container be implemented?(应该如何实现大小受限的 stl 类容器?)
                  Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                  STL BigInt class implementation(STL BigInt 类实现)
                  Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                  Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
                  <tfoot id='GMGqs'></tfoot>
                  • <bdo id='GMGqs'></bdo><ul id='GMGqs'></ul>
                        <tbody id='GMGqs'></tbody>

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