るりまサーチ

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.134秒)
トップページ > 種類:インスタンスメソッド[x] > クエリ:@[x] > クエリ:ref[x] > クラス:MatchData[x]

別のキーワード

  1. fiddle ref
  2. entity ref
  3. pointer ref
  4. _builtin _id2ref
  5. rexml/document ref

ライブラリ

キーワード

検索結果

MatchData#deconstruct_keys(array_of_names) -> Hash (20.0)

引数で指定された名前の名前付きキャプチャを Hash で返します。

...プチャの名前のシンボル、値はキーの名前に対応した名前付きグループのうち最後にマッチした文字列です。

@
param array_of_names 名前付きキャプチャの名前の配列を指定します。nil の場合は全ての名前付きキャプチャを意味...
...{:hours => "18", :minutes => "37", :seconds => "22"}

# 名前付きキャプチャが定義されていなかった場合は空のハッシュを返す
m = /(\d{2}):(\d{2}):(\d{2})/.match("18:37:22")
m.deconstruct_keys(nil) # => {}
//}

@
see d:spec/pattern_matching#matching_non_primitive_objects...

MatchData#captures -> [String] (14.0)

$1, $2, ... を格納した配列を返します。

...$1, $2, ... を格納した配列を返します。

MatchData
#to_a と異なり $& を要素に含みません。
グループにマッチした部分文字列がなければ対応する要素は nil になります。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["...
...foobar", "foo", "bar", nil]
p $~.captures # => ["foo", "bar", nil]
//}

@
see MatchData#to_a, MatchData#named_captures, d:spec/pattern_matching#matching_non_primitive_objects...

MatchData#deconstruct -> [String] (14.0)

$1, $2, ... を格納した配列を返します。

...$1, $2, ... を格納した配列を返します。

MatchData
#to_a と異なり $& を要素に含みません。
グループにマッチした部分文字列がなければ対応する要素は nil になります。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.to_a # => ["...
...foobar", "foo", "bar", nil]
p $~.captures # => ["foo", "bar", nil]
//}

@
see MatchData#to_a, MatchData#named_captures, d:spec/pattern_matching#matching_non_primitive_objects...