Am 28.04.2010 18:08, schrieb cognominal:
On Apr 28, 2:05 pm, mor...@faui2k3.org (Moritz Lenz) wrote:
Am 27.04.2010 06:31, schrieb Stéphane Payrard:
There's also another problem with your approach: If you have
<twigil>?
in your regex, and it matches the empty string, it is still a successful
match - yet with your proposal, it's impossible to distinguis a
successful zero-width match from an unsuccessful match (which can happen
in alternations).
An optional is always a successful match.
That's true, but only half the truth :-)
Consider
^
[
| a b
| <alpha>? c
]
When matched against a string where neither the first nor the second
character is a c, the <alpha>? token won't match - not because of
itself, but because another part of the environment caused the whole
branch not to match.
Moritz