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.