るりまサーチ

最速Rubyリファレンスマニュアル検索!
245件ヒット [1-100件を表示] (0.082秒)
トップページ > クエリ:string[x] > クエリ:@[x] > クエリ:split[x]

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub

検索結果

<< 1 2 3 > >>

String#split(sep = $;, limit = 0) -> [String] (27353.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...なし

@
param sep 文字列を分割するときのセパレータのパターン
@
param 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) と同じ
//}

//emlist[括弧を含む正規表現][ruby]{
p '1-10,20'.split(/([-,])/) # => ["1", "-", "10", ",", "20"]
//}

//emlist[正規表現が空文字列にマッチす...
..."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#partition, String#rpartition...
...の制限はなし

@
param sep 文字列を分割するときのセパレータのパターン
@
param limit 分割する最大個数

@
return ブロックを渡した場合は self、ブロックなしの場合は配列

//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a",...
..." 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) と同じ
//}

//emlist[括弧を含む正規表現][ruby]{
p '1-10,20'.split(/([-,])/) # => [...

String#split(sep = $;, limit = 0) {|s| ... } -> self (27253.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...の制限はなし

@
param sep 文字列を分割するときのセパレータのパターン
@
param limit 分割する最大個数

@
return ブロックを渡した場合は self、ブロックなしの場合は配列

//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a",...
..." 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) と同じ
//}

//emlist[括弧を含む正規表現][ruby]{
p '1-10,20'.split(/([-,])/) # => [...
..."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#partition, String#rpartition...

Shell#split(pathname) -> [String] (18220.0)

File クラスにある同名のクラスメソッドと同じです.

...File クラスにある同名のクラスメソッドと同じです.

@
param pathname パス名を表す文字列を指定します。

@
see File.split...

Shell::CommandProcessor#split(pathname) -> [String] (18220.0)

File クラスにある同名のクラスメソッドと同じです.

...File クラスにある同名のクラスメソッドと同じです.

@
param pathname パス名を表す文字列を指定します。

@
see File.split...

Shell::Filter#split(pathname) -> [String] (18220.0)

File クラスにある同名のクラスメソッドと同じです.

...File クラスにある同名のクラスメソッドと同じです.

@
param pathname パス名を表す文字列を指定します。

@
see File.split...

絞り込み条件を変える

Shellwords.split(line) -> [String] (18220.0)

Bourne シェルの単語分割規則に従った空白区切りの単語分割を行い、 単語 (文字列) の配列を返します。

...列を返します。

このメソッドは、Shellwords.#shellsplit の別名です。

@
param line 分割の対象となる文字列を指定します。
@
return 分割結果の各文字列を要素とする配列を返します。
@
raise ArgumentError 引数の中に対でないシングルク...

URI.split(url) -> [String | nil] (18220.0)

URI を要素に分割した文字列の配列を返します。

...* registry
* path
* opaque
* query
* fragment

@
param url パースしたい URI を文字列として与えます。

@
raise URI::InvalidURIError パースに失敗した場合に発生します。

例:
require 'uri'
p URI.split("http://www.ruby-lang.org/")
#=> ["http", nil, "www....

BigDecimal#split -> [Integer, String, Integer, Integer] (18214.0)

BigDecimal 値を 0.xxxxxxx*10**n と表現したときに、 符号 (NaNのときは 0、それ以外は+1か-1になります)、 仮数部分の文字列("xxxxxxx")と、基数(10)、更に指数 n を配列で返します。

..."
a = BigDecimal("3.14159265")
f, x, y, z = a.split
//}

とすると、f = 1、x = "314159265"、y = 10、z = 1 になります。
従って、以下のようにする事で Float に変換することができます。

//emlist[][ruby]{
s = "0."+x
b = f*(s.to_f)*(y**z)
//}

@
see BigDecimal#to_f...

File.split(pathname) -> [String] (18208.0)

pathname を dirname とbasename に分割して、2 要 素の配列を返します。

...pathname を dirname とbasename に分割して、2 要
素の配列を返します。

//emlist[][ruby]{
[File.dirname(pathname), File.basename(pathname)]
//}

と同じです。

@
param pathname パス名を表す文字列を指定します。...

String#shellsplit -> [String] (15231.0)

Bourne シェルの単語分割規則に従った空白区切りの単語分割を行い、 単語 (文字列) の配列を返します。

...単語分割を行い、
単語 (文字列) の配列を返します。

string
.shellsplit は、Shellwords.shellsplit(string) と等価です。

@
return 分割結果の各文字列を要素とする配列を返します。
@
raise ArgumentError 引数の中に対でないシングルクォートま...
...たはダブル
クォートが現れた場合に発生します。
@
see Shellwords.#shellsplit...

絞り込み条件を変える

String#partition(sep) -> [String, String, String] (9333.0)

セパレータ sep が最初に登場する部分で self を 3 つに分割し、 [最初のセパレータより前の部分, セパレータ, それ以降の部分] の 3 要素の配列を返します。

...

@
param sep セパレータを表す文字列か正規表現を指定します。

//emlist[例][ruby]{
p "axaxa".partition("x") # => ["a", "x", "axa"]
p "aaaaa".partition("x") # => ["aaaaa", "", ""]
p "aaaaa".partition("") # => ["", "", "aaaaa"]
//}

@
see String#rpartition, String#split...
<< 1 2 3 > >>