Lines Matching refs:subject
123 var subject = TO_STRING_INLINE(this);
130 if (index > subject.length) index = subject.length;
132 return %StringIndexOf(subject, pattern, index);
187 var subject = TO_STRING_INLINE(this);
189 if (!regexp.global) return RegExpExecNoTests(regexp, subject, 0);
190 %_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]);
192 return %StringMatch(subject, regexp, lastMatchInfo);
196 return RegExpExecNoTests(regexp, subject, 0);
224 var subject = TO_STRING_INLINE(this);
228 %_Log('regexp', 'regexp-replace,%0r,%1S', [search, subject]);
231 return StringReplaceGlobalRegExpWithFunction(subject, search, replace);
233 return StringReplaceNonGlobalRegExpWithFunction(subject,
238 return %StringReplaceRegExpWithString(subject,
248 subject.length > 0xFF &&
254 return %StringReplaceOneCharWithString(subject, search, replace);
256 var start = %StringIndexOf(subject, search, 0);
257 if (start < 0) return subject;
260 var builder = new ReplaceResultBuilder(subject);
270 subject,
276 ExpandReplacement(replace, subject, reusableMatchInfo, builder);
280 builder.addSpecialSlice(end, subject.length);
288 function ExpandReplacement(string, subject, matchInfo, builder) {
319 builder.addSpecialSlice(matchInfo[CAPTURE1], subject.length);
408 function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
420 subject,
427 return subject;
433 var override = new InternalArray(null, 0, subject);
448 %_CallFunction(receiver, elem, match_start, subject, replace);
468 var resultBuilder = new ReplaceResultBuilder(subject, res);
476 function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
477 var matchInfo = DoRegExpExec(regexp, subject, 0);
478 if (IS_NULL(matchInfo)) return subject;
479 var result = new ReplaceResultBuilder(subject);
484 // and subject for the replace function invocation.
491 var s = SubString(subject, index, endOfMatch);
494 %_CallFunction(receiver, s, index, subject, replace);
498 parameters[j] = CaptureString(subject, matchInfo, j);
501 parameters[j + 1] = subject;
509 result.addSpecialSlice(endOfMatch, subject.length);
586 var subject = TO_STRING_INLINE(this);
592 return [subject];
595 var length = subject.length;
603 // If the separator string is empty then return the elements in the subject.
604 if (separator_length === 0) return %StringToArray(subject, limit);
606 var result = %StringSplit(subject, separator, limit);
614 return StringSplitOnRegExp(subject, separator, limit, length);
618 function StringSplitOnRegExp(subject, separator, limit, length) {
619 %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]);
622 if (DoRegExpExec(separator, subject, 0, 0) != null) {
625 return [subject];
637 result.push(SubString(subject, currentIndex, length));
641 var matchInfo = DoRegExpExec(separator, subject, startIndex);
643 result.push(SubString(subject, currentIndex, length));
655 result.push(%_StringCharAt(subject, currentIndex));
657 result.push(%_SubString(subject, currentIndex, startMatch));
668 result.push(%_StringCharAt(subject, start));
670 result.push(%_SubString(subject, start, end));