UNCONFIRMED 103822
RegExp.prototype.exec should always update lastIndex if no match was found
https://bugs.webkit.org/show_bug.cgi?id=103822
Summary RegExp.prototype.exec should always update lastIndex if no match was found
André Bargull
Reported 2012-12-01 16:54:57 PST
Steps to reproduce: Simple test case: --- js> r = /a/; r.lastIndex = 1; r.exec("zzzz"); r.lastIndex 1 --- Actual results: `r.lastIndex` should have been set to `0` per ES5.1, cf. [15.10.6.2 RegExp.prototype.exec(string) - step 9a]. Spidermonkey and V8 also return `1` whereas IE10 and Opera12 return `0`.
Attachments
André Bargull
Comment 1 2012-12-01 17:12:54 PST
RegExp.prototype.test, String.prototype.match and String.prototype.replace are also affected. List of different javascript engines/browsers and the result for each test: --- r = /a/; r.lastIndex = 1; r.exec("zzzz"); r.lastIndex Bad: JSC, V8, SM Good: Opera, IE r = /a/; r.lastIndex = 1; r.test("zzzz"); r.lastIndex Bad: JSC, V8, SM, Opera Good: IE r = /a/; r.lastIndex = 1; "zzzz".match(r); r.lastIndex Bad: JSC, V8, SM Good: Opera, IE r = /a/; r.lastIndex = 1; "zzzz".replace(r, ""); r.lastIndex Bad: JSC, V8, SM, Opera Good: IE ---
Note You need to log in before you can comment on or make changes to this bug.