Boost logo

Boost Users :

From: brad_at_[hidden]
Date: 2008-05-25 09:58:32


Small problem with match_results. Hope somone can help. On file1.txt, I
match ten times. That is correct. On file2.txt, I match 5 times... as you
can see, that is incorrect. For some reason, I only match the first
column. Source code is at the bottom. Any ideas?

Thanks... Brad

content of file1.txt:

1111
2222
3333
4444
5555
6666
7777
8888
9999
0000

content of file2.txt:

1111 2222
3333 4444
5555 6666
7777 8888
9999 0000

c++ Boost Regex Source:

int main()
  {
    long long total = 0;
    std::string line;
    boost::regex re( "\\b\\d{4}\\b" );
    boost::smatch matches;

    while (std::cin)
      {
        std::getline(std::cin, line);

        if (boost::regex_search(line, matches, re))
          {
          std::cout << matches << std::endl;
          ++total;
          }
      }

  std::cout << total << " matches" << std::endl;
  return 0;
  }


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net