FF1.5 RegExp bug?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

FF1.5 RegExp bug?

harry-6
This code:

  var re=/(co|com)/i;
  re.exec("gg.com/xx");


returns "co" as match.
shouldn't it be "com" as of maximum match principle?
is this a bug?

changing it to /(com/co)/i works like expected.

BTW: Sorry if this is not correct group.
_______________________________________________
Mozilla-seamonkey mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-seamonkey
Reply | Threaded
Open this post in threaded view
|

Re: FF1.5 RegExp bug?

Karsten Düsterloh
harry aber hob zu reden an und schrieb:
> This code:
>
> var re=/(co|com)/i; re.exec("gg.com/xx");
>
> returns "co" as match. shouldn't it be "com" as of maximum match
> principle?

Not in ECMAScript 262:

> 15.10.2.3 Disjunction
...

> Informative comments: The | regular expression operator separates two
> alternatives. The pattern first tries to match the left Alternative
> (followed by the sequel of the regular expression); if it fails, it
> tries to match the right Disjunction (followed by the sequel of the
> regular expression). If the left Alternative, the right Disjunction,
> and the sequel all have choice points, all choices in the sequel are
> tried before moving on to the next choice in the left Alternative. If
> choices in the left Alternative are exhausted, the right Disjunction
> is tried instead of the left Alternative. Any capturing parentheses
> inside a portion of the pattern skipped by | produce undefined values
> instead of strings. Thus, for example,
> /a|ab/.exec("abc")
> returns the result "a" and not "ab". Moreover,
> /((a)|(ab))((c)|(bc))/.exec("abc")
> returns the array
> ["abc", "a", "a", undefined, "bc", undefined, "bc"]
> and not
> ["abc", "ab", undefined, "ab", "c", "c", undefined]


> is this a bug?

Well, it's hard to argue against a standard. ;-)

> BTW: Sorry if this is not correct group.

This is not the correct group. :)
netscape.public.mozilla.jseng would have been more appropriate, I'd guess.


Karsten
--
       Freiheit stirbt        |       Fsayannes SF&F-Bibliothek:
            Mit Sicherheit    |       http://fsayanne.tprac.de/
_______________________________________________
Mozilla-seamonkey mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-seamonkey
Reply | Threaded
Open this post in threaded view
|

Re: FF1.5 RegExp bug?

harry-6
thanks!

Karsten Düsterloh wrote:

> harry aber hob zu reden an und schrieb:
>> This code:
>>
>> var re=/(co|com)/i; re.exec("gg.com/xx");
>>
>> returns "co" as match. shouldn't it be "com" as of maximum match
>> principle?
>
> Not in ECMAScript 262:
>
>> 15.10.2.3 Disjunction
> ...
>> Informative comments: The | regular expression operator separates two
>> alternatives. The pattern first tries to match the left Alternative
>> (followed by the sequel of the regular expression); if it fails, it
>> tries to match the right Disjunction (followed by the sequel of the
>> regular expression). If the left Alternative, the right Disjunction,
>> and the sequel all have choice points, all choices in the sequel are
>> tried before moving on to the next choice in the left Alternative. If
>> choices in the left Alternative are exhausted, the right Disjunction
>> is tried instead of the left Alternative. Any capturing parentheses
>> inside a portion of the pattern skipped by | produce undefined values
>> instead of strings. Thus, for example,
>> /a|ab/.exec("abc")
>> returns the result "a" and not "ab". Moreover,
>> /((a)|(ab))((c)|(bc))/.exec("abc")
>> returns the array
>> ["abc", "a", "a", undefined, "bc", undefined, "bc"]
>> and not
>> ["abc", "ab", undefined, "ab", "c", "c", undefined]
>
>
>> is this a bug?

then it's not a bug but a feature :-)

>
> Well, it's hard to argue against a standard. ;-)
>

yes

>> BTW: Sorry if this is not correct group.
>
> This is not the correct group. :)
> netscape.public.mozilla.jseng would have been more appropriate, I'd guess.
>
subscribed now


Harry
_______________________________________________
Mozilla-seamonkey mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-seamonkey