28件ヒット
[1-28件を表示]
(0.037秒)
ライブラリ
- ビルトイン (28)
検索結果
先頭3件
-
String
# split(sep = $ ; , limit = 0) -> [String] (27498.0) -
第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。
...//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]
p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ') # => ["a", "b", "c"] # split(nil) と同じ
p " a \t b \n c".split # => ["a", "b", "c"] # split(nil) と同じ
//......a", "b", "c", "d", "e"]
p "a,b,c,d,e".split(/,/, 6) # => ["a", "b", "c", "d", "e"]
p "a,b,c,d,e".split(/,/, 7) # => ["a", "b", "c", "d", "e"]
//}
//emlist[limit が負の数の場合は制限なく分割][ruby]{
p "a,b,c,,,".split(/,/, -1) # => ["a", "b", "c", "", "", ""]
//}
@see String#part......ition, String#rpartition... -
String
# split(sep = $ ; , limit = 0) {|s| . . . } -> self (27398.0) -
第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。
...//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]
p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ') # => ["a", "b", "c"] # split(nil) と同じ
p " a \t b \n c".split # => ["a", "b", "c"] # split(nil) と同じ
//......a", "b", "c", "d", "e"]
p "a,b,c,d,e".split(/,/, 6) # => ["a", "b", "c", "d", "e"]
p "a,b,c,d,e".split(/,/, 7) # => ["a", "b", "c", "d", "e"]
//}
//emlist[limit が負の数の場合は制限なく分割][ruby]{
p "a,b,c,,,".split(/,/, -1) # => ["a", "b", "c", "", "", ""]
//}
@see String#part......ition, String#rpartition... -
String
# unpack(template) -> Array (9385.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...@param template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるものは、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることができます......数サイズ非依存 (ネットワークプロトコルなどに適切)
//emlist{
n: big endian unsigned 16bit
N: big endian unsigned 32bit
v: little endian unsigned 16bit
V: little endian unsigned 32bit
//}
: エンディアン依存、整数サイズ依存 (C の構造体などに適切)......どに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレート文字の説明
説明中、Array#pack と String#unpack で違いのあるもの......m template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるものは、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることがで...