Boost logo

Boost Users :

Subject: Re: [Boost-users] pathological regex?
From: John Maddock (john_at_[hidden])
Date: 2009-08-28 07:19:36


>> And more to the point, did you rebuild the regex library with
>> BOOST_REGEX_RECURSIVE set?
>
> I've installed boost libs just by typing sudo apt-get install
> libboost1.37-dev so I've never compiled the library.
> I thought all I should do is to uncomment #define
> BOOST_REGEX_RECURSIVE in boost/regex/user.hpp and rebuild my project.
> I'll try to dwonload sources and biuld regex from it.
>
> BTW - can you give me some tips how can I improve performance when
> matching regex I've mentioned? Maybe there is possibility to optimize
> it by using some more sophisticated expressions form perl syntax?

The basic idea is to make each alternative mutually exclusive, so for
example given:

[something]*[something-else]*

If "something" and "something-else" are mutually exclusive then you should
never get pathological behavior, if they're not exclusive then long runs of
whatever they have in common can trigger problems.

Otherwise it's more down to your code - avoid temporary strings and
match_results, and avoid creating regular expressions "on the fly". That's
why I suggested that you post a test case.

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