string.c: docs for String#split
* string.c: [DOC] clarify docs for String#split when called with limit and capture groups. Reported by Cichol Tsai. [ruby-core:81505] [Bug #13621] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cd4cbc7bca
commit
038c2e52d8
12
string.c
12
string.c
@ -7285,7 +7285,7 @@ static const char isspacetable[256] = {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* str.split(pattern=nil, [limit]) -> anArray
|
* str.split(pattern=nil, [limit]) -> an_array
|
||||||
*
|
*
|
||||||
* Divides <i>str</i> into substrings based on a delimiter, returning an array
|
* Divides <i>str</i> into substrings based on a delimiter, returning an array
|
||||||
* of these substrings.
|
* of these substrings.
|
||||||
@ -7305,9 +7305,11 @@ static const char isspacetable[256] = {
|
|||||||
* split on whitespace as if ' ' were specified.
|
* split on whitespace as if ' ' were specified.
|
||||||
*
|
*
|
||||||
* If the <i>limit</i> parameter is omitted, trailing null fields are
|
* If the <i>limit</i> parameter is omitted, trailing null fields are
|
||||||
* suppressed. If <i>limit</i> is a positive number, at most that number of
|
* suppressed. If <i>limit</i> is a positive number, at most that number
|
||||||
* fields will be returned (if <i>limit</i> is <code>1</code>, the entire
|
* of split substrings will be returned (captured groups will be returned
|
||||||
* string is returned as the only entry in an array). If negative, there is no
|
* as well, but are not counted towards the limit).
|
||||||
|
* If <i>limit</i> is <code>1</code>, 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
|
* limit to the number of fields returned, and trailing null fields are not
|
||||||
* suppressed.
|
* 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,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) #=> []
|
* "".split(',', -1) #=> []
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user