diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-23 07:48:31 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-23 07:48:31 +0000 |
commit | 873c37ce4f2a2f0a79053c68d78934338573897d (patch) | |
tree | 778bfecc494c3b2ac5781dbbf972788a9edd23b5 /string.c | |
parent | b1b4772f0b84bedde34ca5344e2dafafbeebff72 (diff) |
merge revision(s) 59002: [Backport #13621]
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/branches/ruby_2_4@59403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -7188,7 +7188,7 @@ static const char isspacetable[256] = { /* * 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 * of these substrings. @@ -7208,9 +7208,11 @@ static const char isspacetable[256] = { * split on whitespace as if ' ' were specified. * * 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 - * fields will be returned (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 + * suppressed. If <i>limit</i> 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 <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 * suppressed. * @@ -7230,6 +7232,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) #=> [] */ |