Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2007-01-19 04:41:10


Winson Yung wrote:
> Hello, I am using the following pesudo code to do a regex match on big
> buffer (25K of text), sometimes it takes a little longer to come back
> with a result. I know this partly because the way my regular
> expression pattern is structured, but I am just wondering whether
> boost::regex has a mechanism to cancel the pending matching like this
> one.

Well 25K isn't a very large buffer :-) There is no method to
"asynchronously cancel" a search operation once you start it. However,
there is a failsafe built into Boost.Regex that will cause a
std::runtime_error to be thrown if the complexity of finding a match grows
too large, or takes too long. See the test programs under
libs/regex/test/pathology for examples. If the default failsafes don't kick
in early enough for you, then you may be able to tweek the headers (grep for
estimate_max_state_count) to force cancellation to occur earlier: although
of course you may find this causes perfectly good expressions to fail if you
overdo it.

HTH, John.


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