Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2007-05-31 04:16:30


Eric Niebler wrote:
>> Empty alternatives are not allowed (these are almost always a
>> mistake), but if you really want an empty alternative use (?:) as a
>> placeholder, for example:
>>
>> "|abc" is not a valid expression, but
>> "(?:)|abc" is and is equivalent, also the expression:
>> "(?:abc)??" has exactly the same effect.
>
> This would seem to be non-compliant behavior according to TR1, which
> references ECMA-262, which describes the regex syntax in section
> 15.10.1 as:

Quite possibly, although I note that Perl 6 (last time I checked anyway) was
planning to disallow these, on the grounds that they are a persistent source
of buggy regular expressions. And as noted there are alternatives:

|abc == (?:abc)?? == (?:)|abc
abc| == (?:abc)? == abc|(?:)

John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk