[regex] problem with pattern match in 1.33.0

I am having a problem with a regex_match in Boost 1.33.0. Perhaps I am missing something; perhaps it is a bug that has been fixed. The pattern "[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([Ee][+-]?\\d+)?" should match only floating-point numbers that can be read by sscanf. (Extra escape characters are for C++, of course.) Yet regex_match returns true for "3.6.5". I guessed that the problem might be in the '(...)?' expression just before the alternative operator '|', so I tried this: "[+-]?(\\d+|\\d+\\.\\d*|\\.\\d+)([Ee][+-]?\\d+)?". With this pattern regex_match returns false for "3.6.5". I am using it, but I consider it a workaround. Can someone explain what I have missed or whether this is a bug? -- Dick Hadsell 914-259-6320 Fax: 914-259-6499 Reply-to: hadsell@blueskystudios.com Blue Sky Studios http://www.blueskystudios.com 44 South Broadway, White Plains, NY 10601

Richard Hadsell wrote:
I am having a problem with a regex_match in Boost 1.33.0. Perhaps I am missing something; perhaps it is a bug that has been fixed.
The pattern "[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([Ee][+-]?\\d+)?" should match only floating-point numbers that can be read by sscanf. (Extra escape characters are for C++, of course.) Yet regex_match returns true for "3.6.5".
I guessed that the problem might be in the '(...)?' expression just before the alternative operator '|', so I tried this: "[+-]?(\\d+|\\d+\\.\\d*|\\.\\d+)([Ee][+-]?\\d+)?". With this pattern regex_match returns false for "3.6.5". I am using it, but I consider it a workaround.
Can someone explain what I have missed or whether this is a bug?
I can't reproduce this with 1.33.1 (there were some regex bugs fixed in the .1 release), my test case is: int main(int argc, char* argv[]) { try { boost::regex e("[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([Ee][+-]?\\d+)?"); std::string text = "3.6.5"; if(boost::regex_match(text, e)) { std::cout << "Matched!!!" << std::endl; } } catch (const std::exception& e) { std::cout << e.what() << std::endl; } return 0; } Can you please try again with 1.33.1? Thanks, John.

John Maddock wrote:
I can't reproduce this with 1.33.1 (there were some regex bugs fixed in the .1 release)...
It's kind of a big deal for me to upgrade our Boost libraries, because of the way we integrate them into our build system. I decided to wait for 1.34.0, which was supposed to be released some time ago. I think I'll wait for it and hope that the bug is fixed, as seems likely. Thanks for checking it with 1.33.1. -- Dick Hadsell 914-259-6320 Fax: 914-259-6499 Reply-to: hadsell@blueskystudios.com Blue Sky Studios http://www.blueskystudios.com 44 South Broadway, White Plains, NY 10601

Richard Hadsell wrote:
John Maddock wrote:
I can't reproduce this with 1.33.1 (there were some regex bugs fixed in the .1 release)...
It's kind of a big deal for me to upgrade our Boost libraries, because of the way we integrate them into our build system. I decided to wait for 1.34.0, which was supposed to be released some time ago. I think I'll wait for it and hope that the bug is fixed, as seems likely.
Oh :-( There were relatively few changes between 1.31.0 and 1.31.1, so you could just patch the boost/regex subdirectory if that would be more acceptable I guess. John.
participants (2)
-
John Maddock
-
Richard Hadsell