# 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:

Let

*S*= ToString(**this**).Let

*A*be a new array created as if by the expression**new Array()**.If

*limit*is**undefined**__or**null**__, let*lim*= 2^{32}-1 __and go to step 4__#; else let*lim*= ToUint32(*limit*)#.__Let

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

*lim*is**NaN**, let*lim*= 0 and go to step 4 (not step 3.4).____If

*lim*is negative, let*lim*= 2^{32}-1 and go to step 4 (not step 3.4).____Let

*lim*be the smaller of*lim*and 2^{32}-1.__

Let

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

*p*= 0.If

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

*lim*= 0, return*A*.If

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

*s*= 0, go to step 31.Let

*q*=*p*.If

*q*=*s*, go to step 28.Call

*SplitMatch*(*R*,*S*,*q*) and let*z*be its MatchResult result.If

*z*is**failure**, go to step 26.*z*must be a State. Let*e*be*z*'s*endIndex*and let*cap*be*z*'s*captures*array.If

*e*=*p*, go to step 26.Let

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

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

Call the

**[[Put]]**method of*A*with arguments*A*.**length**and*T*.If

*A*.**length**= lim, return*A*.Let

*p*=*e*.Let

*i*= 0.If

*i*is equal to the number of elements in*cap*, go to step 10.Let

*i*=*i*+1.__If

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

Call the

**[[Put]]**method of*A*with arguments*A***.length**and*cap*[*i*].If

*A***.length**=*lim*, return*A*.Go to step 21.

Let

*q*=*q*+1.Go to step 11.

Let

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

**[[Put]]**method of*A*with arguments*A***.length**and*T*.Return

*A*.Call

*SplitMatch*(*R*,*S*, 0) and let*z*be its MatchResult result.If

*z*is not**failure**, return*A*.Call the

**[[Put]]**method of*A*with arguments "**0**"*S*.Return

*A*.