#946 bug

WebKit RegExp match Arrays break when using each iterator

Reported by jay | November 26th, 2009 @ 05:15 PM

Due to the WebKit bug at https://bugs.webkit.org/show_bug.cgi?id=31689, the Array#each iterator doesn't quite work as expected when using RegExp matches returned from match/exec, etc. on WebKit-based browsers that use WebKit's JavaScriptCore. (Chrome is therefore unaffected but Safari is; not sure about other WebKit-based browsers like webOS and the like.)

The bug in WebKit has been patched, but older versions before the patch will obviously be affected, including the current version of Safari.

The symptoms of the bug are missing Array entries when captures are undefined, i.e. optional and missing from the tested String.

For instance:

m = /(a)(_)?.+(c)(_)?.+/.exec("abcd");

m.each(function(x) {

Should both produce the following in a console:


But WebKit-based browsers using JavaScriptCore would produce:


Not sure if it's worth fixing or not since it has been fixed in WebKit, but here's a heads up anyway. I found the WebKit bug while using Array#each in Prototype on Safari, so I figured I may as well report it here, too.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins