2.1.88 [ECMA-262-1999] Section 15.5.4.14, String.prototype.split (separator, limit)

V0135:

If separator is a regular expression that contains capturing parentheses, then each time separator is matched the results (#including# __excluding __any #undefined# __empty string__ results) of the capturing parentheses are spliced into the output array. (For example,

"A<B>bold</B>and<CODE>coded</CODE>".split(/<(\/)?([^<>]+)>/) evaluates to the array ["A", #undefined,# "B", "bold", "/", "B", "and", #undefined,# "CODE", "coded", "/", "CODE", ""].)

JScript 5.x does not include empty-string capturing parentheses result values in the output array. Note that such results would be undefined result values according to the base specification however, as specified in [ECMA-262-1999] section 15.10 and its subsections. JScript produces empty string values for unmatched capturing parentheses.

V0136:

When the split method is called, the following steps are taken:

  1. Let S = ToString(this).

  2. Let A be a new array created as if by the expression new Array().

  3. If limit is undefined __or null__, let lim = 232-1 __and go to step 4__#; else let lim = ToUint32(limit)#.

    1. __Let lim = ToInteger(limit) however if an exception is thrown while performing ToInteger ignore the exception and let lim = 0.__

    2. __If lim is NaN, let lim = 0 and go to step 4 (not step 3.4).__

    3. __If lim is negative, let lim = 232-1 and go to step 4 (not step 3.4).__

    4. __Let lim be the smaller of lim and 232-1.__

  4. Let s be the number of characters in S.

  5. Let p = 0.

  6. If separator is a RegExp object (its [[Class]] is "RegExp"), let R = separator; otherwise let R = ToString(separator).

  7. If lim = 0, return A.

  8. If separator is undefined, go to step 33.

  9. If s = 0, go to step 31.

  10. Let q = p.

  11. If q = s, go to step 28.

  12. Call SplitMatch(R, S, q) and let z be its MatchResult result.

  13. If z is failure, go to step 26.

  14. z must be a State. Let e be z's endIndex and let cap be z's captures array.

  15. If e = p, go to step 26.

  16. Let T be a string value equal to the substring of S consisting of the characters at positions p (inclusive) through q (exclusive).

    1. __If T is the empty string, then go to step 19.__

  17. Call the [[Put]] method of A with arguments A.length and T.

  18. If A.length = lim, return A.

  19. Let p = e.

  20. Let i = 0.

  21. If i is equal to the number of elements in cap, go to step 10.

  22. Let i = i+1.

    1. __If cap[i] is the empty string or undefined, go to step 21.__

  23. Call the [[Put]] method of A with arguments A.length and cap[i].

  24. If A.length = lim, return A.

  25. Go to step 21.

  26. Let q = q+1.

  27. Go to step 11.

  28. Let T be a string value equal to the substring of S consisting of the characters at positions p (inclusive) through s (exclusive).

  29. Call the [[Put]] method of A with arguments A.length and T.

  30. Return A.

  31. Call SplitMatch(R, S, 0) and let z be its MatchResult result.

  32. If z is not failure, return A.

  33. Call the [[Put]] method of A with arguments "0" and S.

  34. Return A.