Index: src/js/string.js |
diff --git a/src/js/string.js b/src/js/string.js |
index 40fc099709fa5d6eb94baadf42bb20e000c91c78..498021381a5181e8420a4940ce5e0e4082301e65 100644 |
--- a/src/js/string.js |
+++ b/src/js/string.js |
@@ -20,6 +20,7 @@ var MakeRangeError; |
var MakeTypeError; |
var MaxSimple; |
var MinSimple; |
+var RegExpInitialize; |
var matchSymbol = utils.ImportNow("match_symbol"); |
var replaceSymbol = utils.ImportNow("replace_symbol"); |
var searchSymbol = utils.ImportNow("search_symbol"); |
@@ -33,6 +34,7 @@ utils.Import(function(from) { |
MakeTypeError = from.MakeTypeError; |
MaxSimple = from.MaxSimple; |
MinSimple = from.MinSimple; |
+ RegExpInitialize = from.RegExpInitialize; |
}); |
//------------------------------------------------------------------- |
@@ -159,8 +161,9 @@ function StringMatchJS(pattern) { |
var subject = TO_STRING(this); |
- // Non-regexp argument. |
- var regexp = new GlobalRegExp(pattern); |
+ // Equivalent to RegExpCreate (ES#sec-regexpcreate) |
+ var regexp = %NewObject(GlobalRegExp, GlobalRegExp); |
+ RegExpInitialize(regexp, pattern); |
return regexp[matchSymbol](subject); |
} |
@@ -355,7 +358,10 @@ function StringSearch(pattern) { |
} |
var subject = TO_STRING(this); |
- var regexp = new GlobalRegExp(pattern); |
+ |
+ // Equivalent to RegExpCreate (ES#sec-regexpcreate) |
+ var regexp = %NewObject(GlobalRegExp, GlobalRegExp); |
+ RegExpInitialize(regexp, pattern); |
return %_Call(regexp[searchSymbol], regexp, subject); |
} |