| Index: src/string.js
|
| diff --git a/src/string.js b/src/string.js
|
| index f8efab613f348513fd00648f425f4515b743e803..de35902d4d28d9cb11f33cf99fce19f24eac07a6 100644
|
| --- a/src/string.js
|
| +++ b/src/string.js
|
| @@ -237,50 +237,15 @@ function StringReplace(search, replace) {
|
| // lastMatchArray without erroneously affecting the properties on the global
|
| // RegExp object.
|
| var reusableMatchInfo = [2, -1, -1, "", ""];
|
| -var reusableMatchArray = [ void 0 ];
|
|
|
|
|
| // Helper function for regular expressions in String.prototype.replace.
|
| function StringReplaceRegExp(subject, regexp, replace) {
|
| - // Compute an array of matches; each match is really a list of
|
| - // captures - pairs of (start, end) indexes into the subject string.
|
| - var matches;
|
| - if (regexp.global) {
|
| - matches = DoRegExpExecGlobal(regexp, subject);
|
| - if (matches.length == 0) return subject;
|
| - } else {
|
| - var lastMatchInfo = DoRegExpExec(regexp, subject, 0);
|
| - if (IS_NULL(lastMatchInfo)) return subject;
|
| - reusableMatchArray[0] = lastMatchInfo;
|
| - matches = reusableMatchArray;
|
| - }
|
| -
|
| - // Determine the number of matches.
|
| - var length = matches.length;
|
| -
|
| - // Build the resulting string of subject slices and replacements.
|
| - var result = new ReplaceResultBuilder(subject);
|
| - var previous = 0;
|
| - // The caller of StringReplaceRegExp must ensure that replace is not a
|
| - // function.
|
| replace = ToString(replace);
|
| - if (%StringIndexOf(replace, "$", 0) < 0) {
|
| - for (var i = 0; i < length; i++) {
|
| - var matchInfo = matches[i];
|
| - result.addSpecialSlice(previous, matchInfo[CAPTURE0]);
|
| - result.add(replace);
|
| - previous = matchInfo[CAPTURE1]; // continue after match
|
| - }
|
| - } else {
|
| - for (var i = 0; i < length; i++) {
|
| - var matchInfo = matches[i];
|
| - result.addSpecialSlice(previous, matchInfo[CAPTURE0]);
|
| - ExpandReplacement(replace, subject, matchInfo, result);
|
| - previous = matchInfo[CAPTURE1]; // continue after match
|
| - }
|
| - }
|
| - result.addSpecialSlice(previous, subject.length);
|
| - return result.generate();
|
| + return %StringReplaceRegExpWithString(subject,
|
| + regexp,
|
| + replace,
|
| + lastMatchInfo);
|
| };
|
|
|
|
|
|
|