Boost logo

Boost Users :

Subject: Re: [Boost-users] [Regex] This pattern compiles fine for Perl and PCRE but not for Boost Regex
From: Edward Diener (eldiener_at_[hidden])
Date: 2010-10-18 15:15:01


On 10/18/2010 1:23 PM, David Dawe wrote:
> Boost Regex fails to compile a regular expression such as "{abc}" with
> the error
>
> "Invalid content of repeat range". However, both Perl and PCRE accept
> the regular
>
> expression, treating the "{" as a literal character.
>
> The PCRE man page at http://www.pcre.org/pcre.txt clearly states:
>
> An opening curly bracket that appears in a position where a quantifier
>
> is not allowed, or one that does not match the syntax of a quantifier,
>
> is taken as a literal character.
>
> The Perl regular expression man page at http://perldoc.perl.org/perlre.html
>
> is similar, though not quite as clear:
>
> If a curly bracket occurs in any other context, it is treated as a regular
>
> character. In particular, the lower bound is not optional.
>
> Nevertheless, the behaviour of both PCRE and Perl are the same.
>
> I am currently using Boost 1.39, but I have seen no mention of a change in
>
> this area for more recent versions of Boost Regex.
>
> And finally … my question …
>
> Is there a way in Boost Regex to interpret a "{" as a literal character in
>
> the above context in a Perl regular expression, while still allowing the
>
> "{n,m}" bounded repeat in places where it is syntactically valid?

Use the backslash escape character, as in "\{" to match "{" as a literal
character.


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