Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost Regex Back Reference Issue
From: John Maddock (jz.maddock_at_[hidden])
Date: 2017-07-13 18:20:02


On 13/07/2017 15:03, Nick via Boost-users wrote:
> According to the Boost documentation for Back references
> (http://www.boost.org/doc/libs/1_64_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.back_references) which seems to be the same at least from 1.37 - 1.64.
>
> Quoting a piece of the documentation:
>
> -----
>
> For example the expression:
>
> ^(a*).*\1$
>
> Will match the string:
>
> aaabbaaa
>
> But not the string:
>
> aaabba
>
> -----
>
>
> I'm finding two issues with the example cited.
>
>
> 1. It seems to me that the example of the string which should not
> match, should actually match. Ultimately, shouldn't the engine match
> the marked sub-expression with the first 'a' in order to satisfy the
> backreference?
> I tested this example with Oniguruma and with PHP's PCRE and they both
> matched the string noted here to not match.

Congratulations, you've just spotted a... ahem... 20 year old bug in the
documentation!
>
> 2. The other issue is that when I try this example with the string
> which is posted to not match, the Boost regex engine runs for a while
> and ultimately crashes with a memory error. (seems like it might be an
> endless loop of some sort). Is that a bug?

Works just fine for me here, if you have a complete self-contained test
case (code, plus compiler version, platform and boost version please)
I'll look into it.

Best, John.

---
This email has been checked for viruses by AVG.
http://www.avg.com

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