๐ File Manager Pro
v10.0.3 | PHP: 8.1.34
Server: Apache
2026-06-22 06:13:49
๐
/ (Root)
/
opt
/
alt
/
ruby33
/
share
/
ri
/
system
/
String
๐ /opt/alt/ruby33/share/ri/system/String
๐ Refresh
โ๏ธ
Editing: split-i.ri
Read Only
U:RDoc::AnyMethod[iI" split:ETI"String#split;TF:privateo:RDoc::Markup::Document:@parts[(o:RDoc::Markup::Paragraph; [I".Returns an array of substrings of +self+ ;TI"-that are the result of splitting +self+ ;TI"Aat each occurrence of the given field separator +field_sep+.;To:RDoc::Markup::BlankLine o; ; [I"%When +field_sep+ is <tt>$;</tt>:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"2If <tt>$;</tt> is +nil+ (its default value), ;TI"Mthe split occurs just as if +field_sep+ were given as a space character ;TI"(see below).;T@o;;0; [o; ; [I"!If <tt>$;</tt> is a string, ;TI"Fthe split ocurs just as if +field_sep+ were given as that string ;TI"(see below).;T@o; ; [I"<When +field_sep+ is <tt>' '</tt> and +limit+ is +nil+, ;TI"5the split occurs at each sequence of whitespace:;T@o:RDoc::Markup::Verbatim; [ I"?'abc def ghi'.split(' ') => ["abc", "def", "ghi"] ;TI"B"abc \n\tdef\t\n ghi".split(' ') # => ["abc", "def", "ghi"] ;TI"?'abc def ghi'.split(' ') => ["abc", "def", "ghi"] ;TI",''.split(' ') => [] ;T:@format0o; ; [ I">When +field_sep+ is a string different from <tt>' '</tt> ;TI"and +limit+ is +nil+, ;TI"9the split occurs at each occurrence of +field_sep+; ;TI"0trailing empty substrings are not returned:;T@o;; [I"7'abracadabra'.split('ab') => ["", "racad", "ra"] ;TI"7'aaabcdaaa'.split('a') => ["", "", "", "bcd"] ;TI"&''.split('a') => [] ;TI"5'3.14159'.split('1') => ["3.", "4", "59"] ;TI"B'!@#$%^$&*($)_+'.split('$') # => ["!@#", "%^", "&*(", ")_+"] ;TI"5'ัะตัั'.split('ั') => ["", "ะตั"] ;TI"@'ใใใซใกใฏ'.split('ใซ') => ["ใใ", "ใกใฏ"] ;T;0o; ; [I"8When +field_sep+ is a Regexp and +limit+ is +nil+, ;TI"5the split occurs at each occurrence of a match; ;TI"0trailing empty substrings are not returned:;T@o;; [ I"8'abracadabra'.split(/ab/) # => ["", "racad", "ra"] ;TI"5'aaabcdaaa'.split(/a/) => ["", "", "", "bcd"] ;TI"O'aaabcdaaa'.split(//) => ["a", "a", "a", "b", "c", "d", "a", "a", "a"] ;TI"4'1 + 1 == 2'.split(/\W+/) # => ["1", "1", "2"] ;T;0o; ; [I"EIf the \Regexp contains groups, their matches are also included ;TI"in the returned array:;T@o;; [I"@'1:2:3'.split(/(:)()()/, 2) # => ["1", ":", "", "", "2:3"] ;T;0o; ; [I")As seen above, if +limit+ is +nil+, ;TI"1trailing empty substrings are not returned; ;TI")the same is true if +limit+ is zero:;T@o;; [I"5'aaabcdaaa'.split('a') => ["", "", "", "bcd"] ;TI"8'aaabcdaaa'.split('a', 0) # => ["", "", "", "bcd"] ;T;0o; ; [I"FIf +limit+ is positive integer +n+, no more than <tt>n - 1-</tt> ;TI"@splits occur, so that at most +n+ substrings are returned, ;TI"0and trailing empty substrings are included:;T@o;; [ I"2'aaabcdaaa'.split('a', 1) # => ["aaabcdaaa"] ;TI"5'aaabcdaaa'.split('a', 2) # => ["", "aabcdaaa"] ;TI">'aaabcdaaa'.split('a', 5) # => ["", "", "", "bcd", "aa"] ;TI"D'aaabcdaaa'.split('a', 7) # => ["", "", "", "bcd", "", "", ""] ;TI"D'aaabcdaaa'.split('a', 8) # => ["", "", "", "bcd", "", "", ""] ;T;0o; ; [I">Note that if +field_sep+ is a \Regexp containing groups, ;TI"Ptheir matches are in the returned array, but do not count toward the limit.;T@o; ; [I"JIf +limit+ is negative, it behaves the same as if +limit+ was +nil+, ;TI"%meaning that there is no limit, ;TI"0and trailing empty substrings are included:;T@o;; [I"E'aaabcdaaa'.split('a', -1) # => ["", "", "", "bcd", "", "", ""] ;T;0o; ; [I";If a block is given, it is called with each substring:;T@o;; [I"9'abc def ghi'.split(' ') {|substring| p substring } ;T;0o; ; [I"Output:;T@o;; [I""abc" ;TI""def" ;TI""ghi" ;T;0o; ; [I"2Related: String#partition, String#rpartition.;T: @fileI" string.c;T:0@omit_headings_from_table_of_contents_below0I"osplit(field_sep = $;, limit = nil) -> array split(field_sep = $;, limit = nil) {|substring| ... } -> self ;T0[ I"(p1 = v1, p2 = v2);T@|FI"String;TcRDoc::NormalClass00
๐พ Save Changes
โ Cancel