Opened 14 years ago
Closed 14 years ago
#2058 closed Bugs (worksforme)
boost::regex_replace strange behaviour
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | Component: | regex | |
Version: | Severity: | Problem | |
Keywords: | Cc: |
Description
Dear Boost Representative,
I have encountered a strange boost::reges_replace behaviour.
There is a complete (as small as possible, I think) project to reproduce that error in the attachement.
Generally, when the 'in' variable (std::string) exceedes a critical (indefinite) length boost::regex_replace throws an exception: _STL::runtime_error with message: "Exception Object Address...".
Some further info on my environment: BOOST VERSION: 1.33.1. Borland C++ Builder 6.0 Professional (Build 10.166). Update Pack 4 applied. Windows XP. SP2 applied.
Thank you in advance for any help in this strange matter.
Yours sincerely, Piotr.
Attachments (1)
Change History (2)
by , 14 years ago
Attachment: | Ticket2058_Attachement.ZIP added |
---|
comment:1 by , 14 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
I can't reproduce this as I don't have access to Borland C++ at present.
However, I believe this is caused by the regular expression used: match a regular expression is in general an NP-complete problem so Boost.Regex will throw a std::runtime_error if the complexity of matching grows to much.
The problem appears to be the:
(.|
s)*?
part, the issue is that "." will match all the same characters that "
s" will, so the number of possible alternative ways to find a match grows exponentially large - hence the exception thrown. Changing to:
.*?
will likely solve the problem I believe.
HTH, John Maddock.