るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
1件ヒット [1-1件を表示] (0.033秒)

別のキーワード

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

検索結果

Regexp#named_captures -> { String => [Integer] } (54367.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 を返します。
/(.)(.)/...