ref: 71afe58cc47f22239087bf568fce937c1fde7fed
parent: 9e6b197ce269253a7b38ee8a3c77096202159ce7
author: Tor Andersson <tor@ccxvii.net>
date: Wed Feb 5 09:36:35 EST 2014
Reset the lastIndex property in String.match() and replace().
--- a/jsstring.c
+++ b/jsstring.c
@@ -336,6 +336,8 @@
if (!(re->flags & JS_REGEXP_G))
return js_RegExp_prototype_exec(J, re, text);
+ re->last = 0;
+
js_newarray(J);
e = strlen(text);
@@ -399,6 +401,8 @@
js_copy(J, 0);
return 1;
}
+
+ re->last = 0;
loop:
s = source + m[0].rm_so;