diff --git a/string.c b/string.c index df3f8fd3cd..cd633e1226 100644 --- a/string.c +++ b/string.c @@ -7285,7 +7285,7 @@ static const char isspacetable[256] = { /* * call-seq: - * str.split(pattern=nil, [limit]) -> anArray + * str.split(pattern=nil, [limit]) -> an_array * * Divides str into substrings based on a delimiter, returning an array * of these substrings. @@ -7305,9 +7305,11 @@ static const char isspacetable[256] = { * split on whitespace as if ' ' were specified. * * If the limit parameter is omitted, trailing null fields are - * suppressed. If limit is a positive number, at most that number of - * fields will be returned (if limit is 1, the entire - * string is returned as the only entry in an array). If negative, there is no + * suppressed. If limit is a positive number, at most that number + * of split substrings will be returned (captured groups will be returned + * as well, but are not counted towards the limit). + * If limit is 1, the entire + * string is returned as the only entry in an array. If negative, there is no * limit to the number of fields returned, and trailing null fields are not * suppressed. * @@ -7327,6 +7329,8 @@ static const char isspacetable[256] = { * "1,2,,3,4,,".split(',', 4) #=> ["1", "2", "", "3,4,,"] * "1,2,,3,4,,".split(',', -4) #=> ["1", "2", "", "3", "4", "", ""] * + * "1:2:3".split(/(:)()()/, 2) #=> ["1", ":", "", "", "2:3"] + * * "".split(',', -1) #=> [] */