Status: Accepted
Owner: erik.corry
Labels: Type-Bug Priority-Medium
New issue 176 by erik.corry: Regexp: ? should be implemented as {0,1}
http://code.google.com/p/v8/issues/detail?id=176
According to spec (15.10.2.7), ? should be implemented as {0,1} (0 or 1
repetition).
According to spec (15.10.2.5), a zero length match of the body of a
repetition causes a failure: "If min is zero and y's endIndex is equal to
x's endIndex, then return failure."
This can be seen in the following regexp:
"foo".match(/(?:(?=(f)o))?f/)
Here the ? is greedy so it tries 1 match first then 0 matches.
The contents of the ? match zero length (contain only an assertion) and so
the brackets fail to match once.
The capture of the f is undone and the ? matches 0 times.
The result is "f,". This works as specified in Spidermonkey and
Tracemonkey. In V8 it doesn't work. It seems the Irregexp parser doesn't
like it. In addition, Irregexp and JSCRE both implement the wrong
semantics.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---