Lines Matching refs:replace
194 function StringReplace(search, replace) {
195 CHECK_OBJECT_COERCIBLE(this, "String.prototype.replace");
201 // .... string replace
203 // ........ empty string replace
204 // ........ non-empty string replace (with $-expansion)
208 // .... function replace
213 // ...... function replace
214 // ...... string replace (with $-expansion)
222 if (!IS_SPEC_FUNCTION(replace)) {
223 replace = TO_STRING_INLINE(replace);
226 // Non-global regexp search, string replace.
232 if (replace.length == 0) {
236 return ExpandReplacement(replace, subject, lastMatchInfo,
241 // Global regexp search, string replace.
245 subject, search, replace, lastMatchInfo);
253 subject, search, replace, lastMatchInfo);
264 // Global regexp search, function replace.
265 return StringReplaceGlobalRegExpWithFunction(subject, search, replace);
267 // Non-global regexp search, function replace.
268 return StringReplaceNonGlobalRegExpWithFunction(subject, search, replace);
275 IS_STRING(replace) &&
276 %StringIndexOf(replace, '$', 0) < 0) {
277 // Searching by traversing a cons string tree and replace with cons of
280 return %StringReplaceOneCharWithString(subject, search, replace);
288 // Compute the string to replace with.
289 if (IS_SPEC_FUNCTION(replace)) {
290 var receiver = %GetDefaultReceiver(replace);
291 result += %_CallFunction(receiver, search, start, subject, replace);
295 result = ExpandReplacement(TO_STRING_INLINE(replace),
401 // TODO(lrn): This array will survive indefinitely if replace is never
407 // function application in String.prototype.replace.
408 function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
413 // Inside a nested replace (replace called from the replacement function
414 // of another replace) or we have failed to set the reusable array
435 // input string and some replacements that were returned from the replace
439 var receiver = %GetDefaultReceiver(replace);
456 %_CallFunction(receiver, elem, match_start, subject, replace);
464 var receiver = %GetDefaultReceiver(replace);
471 var func_result = %Apply(replace, receiver, elem, 0, elem.length);
485 function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
495 // and subject for the replace function invocation.
499 var receiver = %GetDefaultReceiver(replace);
504 replacement = %_CallFunction(receiver, s, index, subject, replace);
513 replacement = %Apply(replace, receiver, parameters, 0, j + 2);
833 return TO_STRING_INLINE(str).replace(/"/g, """);
956 "replace", StringReplace,