286件ヒット
[201-286件を表示]
(0.061秒)
クラス
- CSV (12)
- MatchData (86)
- OptionParser (12)
- String (176)
キーワード
- [] (48)
- bytes (24)
- captures (12)
- chars (24)
- codepoints (24)
-
col
_ sep (12) - deconstruct (2)
-
each
_ codepoint (24) -
each
_ grapheme _ cluster (16) -
each
_ line (24) -
grapheme
_ clusters (16) - lines (24)
-
values
_ at (12)
検索結果
先頭5件
-
MatchData
# captures -> [String] (127.0) -
$1, $2, ... を格納した配列を返します。
...た配列を返します。
MatchData#to_a と異なり $& を要素に含みません。
グループにマッチした部分文字列がなければ対応する要素は nil になります。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", ni......l]
p $~.captures # => ["foo", "bar", nil]
//}
@see MatchData#to_a, MatchData#named_captures, d:spec/pattern_matching#matching_non_primitive_objects... -
MatchData
# deconstruct -> [String] (127.0) -
$1, $2, ... を格納した配列を返します。
...た配列を返します。
MatchData#to_a と異なり $& を要素に含みません。
グループにマッチした部分文字列がなければ対応する要素は nil になります。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", ni......l]
p $~.captures # => ["foo", "bar", nil]
//}
@see MatchData#to_a, MatchData#named_captures, d:spec/pattern_matching#matching_non_primitive_objects... -
MatchData
# captures -> [String] (126.0) -
$1, $2, ... を格納した配列を返します。
...た配列を返します。
MatchData#to_a と異なり $& を要素に含みません。
グループにマッチした部分文字列がなければ対応する要素は nil になります。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", ni......l]
p $~.captures # => ["foo", "bar", nil]
//}
@see MatchData#to_a, MatchData#named_captures... -
CSV
# col _ sep -> String (120.0) -
カラム区切り文字列として使用する文字列を返します。
...字列を返します。
//emlist[例][ruby]{
require "csv"
users =<<-EOS
id|first name|last name|age
1|taro|tanaka|20
2|jiro|suzuki|18
3|ami|sato|19
4|yumi|adachi|21
EOS
csv = CSV.new(users, headers: true, col_sep: "|")
csv.col_sep # => "|"
csv.first.to_a # => [["id", "1"], ["first name", "taro"......], ["last name", "tanaka"], ["age", "20"]]
csv = CSV.new(users, headers: true)
csv.col_sep # => ","
csv.first.to_a # => [["id|first name|last name|age", "1|taro|tanaka|20"]]
//}
@see CSV.new... -
MatchData
# [](n) -> String | nil (120.0) -
n 番目の部分文字列を返します。
...い時には nil を返します。
@param n 返す部分文字列のインデックスを指定します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["foobar", "foo", "bar", nil]
p $~[0] # => "foobar"
p $~[1] # => "foo"
p $~[2] # => "bar"... -
MatchData
# values _ at(*index) -> [String] (120.0) -
正規表現中の n 番目の括弧にマッチした部分文字列の配列を返します。
...][ruby]{
m = /(foo)(bar)(baz)/.match("foobarbaz")
# same as m.to_a.values_at(...)
p m.values_at(0, 1, 2, 3, 4) # => ["foobarbaz", "foo", "bar", "baz", nil]
p m.values_at(-1, -2, -3, -4, -5) # => ["baz", "bar", "foo", nil, nil]
m = /(?<a>\d+) *(?<op>[+\-*\/]) *(?<b>\d+)/.match("1 + 2")
m.to_a... -
MatchData
# [](name) -> String | nil (115.0) -
name という名前付きグループにマッチした文字列を返します。
...m name 名前(シンボルか文字列)
@raise IndexError 指定した名前が正規表現内に含まれていない場合に発生します
//emlist[例][ruby]{
/\$(?<dollars>\d+)\.(?<cents>\d+)/.match("$3.67")[:cents] # => "67"
/(?<alpha>[a-zA-Z]+)|(?<num>\d+)/.match("aZq")[:num] # => nil
//}... -
MatchData
# [](range) -> [String] (115.0) -
Range オブジェクト range の範囲にある要素からなる部分配列を返します。
...Range オブジェクト range の範囲にある要素からなる部分配列を返します。
@param range start..end 範囲式。
//emlist[例][ruby]{
/(foo)(bar)/ =~ "foobarbaz"
p $~[0..2] # => ["foobar", "foo", "bar"]
//}... -
MatchData
# [](start , length) -> [String] (115.0) -
start 番目から length 個の要素を含む部分配列を返します。
...start 番目から length 個の要素を含む部分配列を返します。
//emlist[例][ruby]{
/(foo)(bar)/ =~ "foobarbaz"
p $~[0, 3] # => ["foobar", "foo", "bar"]
//}
@see Array#[]...