D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby18
/
share
/
ri
/
1.8
/
system
/
String
/
Filename :
split-i.yaml
back
Copy
--- !ruby/object:RI::MethodDescription aliases: [] block_params: comment: - !ruby/struct:SM::Flow::P body: Divides <em>str</em> into substrings based on a delimiter, returning an array of these substrings. - !ruby/struct:SM::Flow::P body: If <em>pattern</em> is a <tt>String</tt>, then its contents are used as the delimiter when splitting <em>str</em>. If <em>pattern</em> is a single space, <em>str</em> is split on whitespace, with leading whitespace and runs of contiguous whitespace characters ignored. - !ruby/struct:SM::Flow::P body: If <em>pattern</em> is a <tt>Regexp</tt>, <em>str</em> is divided where the pattern matches. Whenever the pattern matches a zero-length string, <em>str</em> is split into individual characters. - !ruby/struct:SM::Flow::P body: If <em>pattern</em> is omitted, the value of <tt>$;</tt> is used. If <tt>$;</tt> is <tt>nil</tt> (which is the default), <em>str</em> is split on whitespace as if ` ' were specified. - !ruby/struct:SM::Flow::P body: If the <em>limit</em> parameter is omitted, trailing null fields are suppressed. If <em>limit</em> is a positive number, at most that number of fields will be returned (if <em>limit</em> is <tt>1</tt>, 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. - !ruby/struct:SM::Flow::VERB body: " " now's the time".split #=> ["now's", "the", "time"]\n " now's the time".split(' ') #=> ["now's", "the", "time"]\n " now's the time".split(/ /) #=> ["", "now's", "", "the", "time"]\n "1, 2.34,56, 7".split(%r{,\\s*}) #=> ["1", "2.34", "56", "7"]\n "hello".split(//) #=> ["h", "e", "l", "l", "o"]\n "hello".split(//, 3) #=> ["h", "e", "llo"]\n "hi mom".split(%r{\\s*}) #=> ["h", "i", "m", "o", "m"]\n\n "mellow yellow".split("ello") #=> ["m", "w y", "w"]\n "1,2,,3,4,,".split(',') #=> ["1", "2", "", "3", "4"]\n "1,2,,3,4,,".split(',', 4) #=> ["1", "2", "", "3,4,,"]\n "1,2,,3,4,,".split(',', -4) #=> ["1", "2", "", "3", "4", "", ""]\n" full_name: String#split is_singleton: false name: split params: | str.split(pattern=$;, [limit]) => anArray visibility: public