Boost logo

Boost Users :

From: Andrew Dennison (adenniso_at_[hidden])
Date: 2004-09-12 11:53:56


I have having a problem determining if the regex library is working
properly. I have run the regex regression tests, and all tests in the
test.txt file pass. My problem however began with the following
match:

string: "orange and ba.ana and kiwi"
expression: "\\.([a-z]+).*[ \t\n].*\\.([a-z]+)"
expected result: match, captures 'range' and 'ana'
real result: no match

The code in question is this:

    bool result = false;
    std::string str = "orange and ba.ana and kiwi";
    std::string exp(".([a-z]+).*[ \t\n].*\\.([a-z]+)");
    try {
      boost::smatch what;
      boost::regex e(exp.c_str());
      // use default format flags
      result = regex_match(str, what, e);
      if (result) {
        ...
      }
    } catch (std::runtime_error &e) {
      ...
    }
    ...

It seems to consistently fail. This same example works in both Java and
Perl, and with the PCRE C++ regex library. No exception is being caught
either.

I posted the actual code to show that i don't think i'm doing anything
particularly unique - i call regex_match (though even regex_search fails
to match). I even tried formatting a file for the regression test
harness with this example, and it confirmed that this particular example
does not succeed.

Can someone please provide suggestions regarding:
a) what is going wrong
b) how to fix it

It should be noted that i'm running linux, boost version 1.31.0, with
the regex patch installed.

Thanks.


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