Reset the lastIndex property in String.match() and replace().

This commit is contained in:
Tor Andersson
2014-02-05 14:36:35 +01:00
parent 9e6b197ce2
commit 71afe58cc4

View File

@@ -336,6 +336,8 @@ static int Sp_match(js_State *J, int argc)
if (!(re->flags & JS_REGEXP_G))
return js_RegExp_prototype_exec(J, re, text);
re->last = 0;
js_newarray(J);
e = strlen(text);
@@ -400,6 +402,8 @@ static int Sp_replace_regexp(js_State *J, int argc)
return 1;
}
re->last = 0;
loop:
s = source + m[0].rm_so;
n = m[0].rm_eo - m[0].rm_so;