Re: [Boost-bugs] [Boost C++ Libraries] #2058: boost::regex_replace strange behaviour

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2058: boost::regex_replace strange behaviour
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-07-24 12:31:23


#2058: boost::regex_replace strange behaviour
---------------------------------------+------------------------------------
  Reporter: piotr.pydych_at_[hidden] | Owner: johnmaddock
      Type: Bugs | Status: closed
 Milestone: | Component: regex
   Version: | Severity: Problem
Resolution: worksforme | Keywords:
---------------------------------------+------------------------------------
Changes (by johnmaddock):

  * status: new => closed
  * resolution: => worksforme

Comment:

 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.

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2058#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC