るりまサーチ

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

別のキーワード

  1. _builtin named_captures
  2. regexp named_captures
  3. matchdata named_captures
  4. ec named_curve
  5. openssl named_curve

ライブラリ

クラス

検索結果

MatchData#named_captures -> Hash (18254.0)

名前付きキャプチャをHashで返します。

...プチャをHashで返します。

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

//emlist[例][ruby]{
m = /(?<a>.)(?<b>.)/.match("01")
m.named_captures # => {"a" =>...
..."0", "b" => "1"}

m = /(?<a>.)(?<b>.)?/.match("0")
m.named_captures # => {"a" => "0", "b" => nil}

m = /(?<a>.)(?<a>.)/.match("01")
m.named_captures # => {"a" => "1"}

m = /(?<a>x)|(?<a>y)/.match("x")
m.named_captures # => {"a" => "x"}
//}

@see MatchData#captures...

Regexp#named_captures -> { String => [Integer] } (18147.0)

正規表現に含まれる名前付きキャプチャ(named capture)の情報を Hash で返します。

...ャ(named capture)の情報を
Hash
で返します。

Hash
のキーは名前付きキャプチャの名前で、値は
その名前に関連付けられたキャプチャの index のリストを返します。

//emlist[例][ruby]{
/(?<foo>.)(?<bar>.)/.named_captures
# => {"foo"=>[1], "bar"=>[2]...
...}

/(?<foo>.)(?<foo>.)/.named_captures
# => {"foo"=>[1, 2]}

# 名前付きキャプチャを持たないときは空の Hash を返します。
/(.)(.)/.named_captures
# => {}
//}...

NEWS for Ruby 2.4.0 (36.0)

NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...になりました。
half には :even, :up, :down が指定可能です。 12548 12958 12953

* Hash
* Hash#compact, Hash#compact! を追加 11818
* Hash#transform_values Hash#transform_values! を追加 12512

* Integer
* Fixnum と Bignum は Integer に統合されまし...
...Kernel#clone は freeze というキーワード引数を受け付けるようになりました。
12300

* MatchData
* MatchData#named_captures を追加 11999
* MatchData#values_at は named captures をサポートするようになりました 9179

* Module
* Module#refin...