|
Boost : |
From: impulse9 (impulse9_at_[hidden])
Date: 2007-06-01 18:12:52
John Maddock wrote:
JM> 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:
JM> Quite possibly, although I note that Perl 6 (last time I checked anyway) was
JM> planning to disallow these, on the grounds that they are a persistent source
JM> of buggy regular expressions. And as noted there are alternatives:
JM> |abc == (?:abc)?? == (?:)|abc
JM> abc| == (?:abc)? == abc|(?:)
JM> John.
Disallowing these would do more bad than good. Buggy regular expressions
are quite easy to write, even without '|)'
Using |) is quite intuitive. We have a lot of cases than some
symbol(s) may or may not be present, and this is a natural way to say that.
Moreover it makes regular expressions more flexible.
This is from http://en.wikipedia.org/wiki/Regular_expression
[QUOTE]
Regular expressions are particularly useful in the production of code
completion systems and syntax highlighting in integrated development environments (IDEs).
For example:
(public|private|protected|)\s*(\w+)\s+(\w+)\s*\(
as used to match type declarations in source code (see also, Regular expression examples ).
[/QUOTE]
Alternatives are just alternatives. Or should we assume that
boost::regex is only Perl6+ compatible?
That's imho.
Thank you.
-- impulse9
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk