種類
- インスタンスメソッド (109)
- 文書 (92)
- 変数 (44)
- 特異メソッド (33)
- モジュール関数 (22)
ライブラリ
- English (22)
- ビルトイン (102)
- bigdecimal (11)
- shell (6)
-
shell
/ command-processor (6) -
shell
/ filter (6) - shellwords (44)
- uri (11)
クラス
- Array (19)
- BigDecimal (11)
- File (11)
- Shell (6)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (6) - String (61)
モジュール
- Kernel (44)
- Shellwords (33)
- URI (11)
キーワード
-
$ -F (11) -
$ ; (11) -
$ FIELD _ SEPARATOR (11) -
$ FS (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
- Rubyの起動 (11)
- pack (19)
- pack テンプレート文字列 (11)
- partition (11)
- rpartition (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) - shellsplit (22)
- shellwords (11)
- split (79)
- unpack (11)
検索結果
先頭5件
-
String
# split(sep = $ ; , limit = 0) -> [String] (62329.0) -
第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。
...][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[......'.split(/([-,])/) # => ["1", "-", "10", ",", "20"]
//}
//emlist[正規表現が空文字列にマッチする場合は 1 文字に分割][ruby]{
p 'hi there'.split(/\s*/).join(':') # => "h:i:t:h:e:r:e"
//}
//emlist[文字列全体を 1 文字ずつに分割する例][ruby]{
p 'hi there'.split(/......,,,".split(/,/, 0) # => ["a", "b", "c"]
//}
//emlist[limit 省略時は 0 と同じ (最もよく使われるパターン)][ruby]{
p "a,b,c,,,".split(/,/) # => ["a", "b", "c"]
//}
//emlist[正の limit 使用例][ruby]{
p "a,b,c,d,e".split(/,/, 1) # => ["a,b,c,d,e"]
p "a,b,c,d,e".split(/,/... -
String
# split(sep = $ ; , limit = 0) {|s| . . . } -> self (62229.0) -
第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。
...][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[......'.split(/([-,])/) # => ["1", "-", "10", ",", "20"]
//}
//emlist[正規表現が空文字列にマッチする場合は 1 文字に分割][ruby]{
p 'hi there'.split(/\s*/).join(':') # => "h:i:t:h:e:r:e"
//}
//emlist[文字列全体を 1 文字ずつに分割する例][ruby]{
p 'hi there'.split(/......,,,".split(/,/, 0) # => ["a", "b", "c"]
//}
//emlist[limit 省略時は 0 と同じ (最もよく使われるパターン)][ruby]{
p "a,b,c,,,".split(/,/) # => ["a", "b", "c"]
//}
//emlist[正の limit 使用例][ruby]{
p "a,b,c,d,e".split(/,/, 1) # => ["a,b,c,d,e"]
p "a,b,c,d,e".split(/,/... -
String
# shellsplit -> [String] (27213.0) -
Bourne シェルの単語分割規則に従った空白区切りの単語分割を行い、 単語 (文字列) の配列を返します。
...の単語分割規則に従った空白区切りの単語分割を行い、
単語 (文字列) の配列を返します。
string.shellsplit は、Shellwords.shellsplit(string) と等価です。
@return 分割結果の各文字列を要素とする配列を返します。
@raise ArgumentError 引......数の中に対でないシングルクォートまたはダブル
クォートが現れた場合に発生します。
@see Shellwords.#shellsplit... -
String
# partition(sep) -> [String , String , String] (21327.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... -
String
# rpartition(sep) -> [String , String , String] (21327.0) -
セパレータ sep が最後に登場する部分で self を 3 つに分割し、 [最後のセパレータより前の部分, セパレータ, それ以降の部分] の 3 要素の配列を返します。
...と第 2 要素が空文字列になります。
@param sep セパレータを表す文字列か正規表現を指定します。
//emlist[例][ruby]{
p "axaxa".rpartition("x") # => ["axa", "x", "a"]
p "aaaaa".rpartition("x") # => ["", "", "aaaaa"]
//}
@see String#partition, String#split... -
String
# unpack(template) -> Array (21048.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...@param template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるものは、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることができます......!<: little endian signed long
//}
=== 各テンプレート文字の説明
説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の説明 / String#unpack の説明」としています。
: a
ASCII文字列(ヌル文字を詰める/後続する......=> "a\x00b"
[97, 98].pack("Cx3C") # => "a\x00\x00\x00b"
"abc".unpack("CxC") # => [97, 99]
"abc".unpack("Cx3C") # => ArgumentError: x outside of string
//}
: X
1バイト後退
//emlist[][ruby]{
[97, 98, 99].pack("CCXC") # => "ac"
"abcdef".unpack("x*XC") # => [102]
//}
: @
絶対位置......m template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるものは、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることがで... -
BigDecimal
# split -> [Integer , String , Integer , Integer] (18208.0) -
BigDecimal 値を 0.xxxxxxx*10**n と表現したときに、 符号 (NaNのときは 0、それ以外は+1か-1になります)、 仮数部分の文字列("xxxxxxx")と、基数(10)、更に指数 n を配列で返します。
...")と、基数(10)、更に指数 n を配列で返します。
//emlist[][ruby]{
require "bigdecimal"
a = BigDecimal("3.14159265")
f, x, y, z = a.split
//}
とすると、f = 1、x = "314159265"、y = 10、z = 1 になります。
従って、以下のようにする事で Float に変換する... -
Shell
# split(pathname) -> [String] (18208.0) -
File クラスにある同名のクラスメソッドと同じです.
...File クラスにある同名のクラスメソッドと同じです.
@param pathname パス名を表す文字列を指定します。
@see File.split... -
Shell
:: CommandProcessor # split(pathname) -> [String] (18208.0) -
File クラスにある同名のクラスメソッドと同じです.
...File クラスにある同名のクラスメソッドと同じです.
@param pathname パス名を表す文字列を指定します。
@see File.split... -
Shell
:: Filter # split(pathname) -> [String] (18208.0) -
File クラスにある同名のクラスメソッドと同じです.
...File クラスにある同名のクラスメソッドと同じです.
@param pathname パス名を表す文字列を指定します。
@see File.split... -
URI
. split(url) -> [String | nil] (18208.0) -
URI を要素に分割した文字列の配列を返します。
...fragment
@param url パースしたい URI を文字列として与えます。
@raise URI::InvalidURIError パースに失敗した場合に発生します。
例:
require 'uri'
p URI.split("http://www.ruby-lang.org/")
#=> ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]...