41件ヒット
[1-41件を表示]
(0.147秒)
検索結果
先頭4件
-
Regexp
# named _ captures -> { String => [Integer] } (27319.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
# => {}
//}... -
MatchData
# named _ captures -> Hash (24325.0) -
名前付きキャプチャをHashで返します。
...t[例][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... -
MatchData
# captures -> [String] (6206.0) -
$1, $2, ... を格納した配列を返します。
...ープにマッチした部分文字列がなければ対応する要素は 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... -
NEWS for Ruby 2
. 4 . 0 (3072.0) -
NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.4.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......hangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 2.3.0 以降の変更
=== 言語仕様の変更
* 条件式での多重代入ができるようになりました 10617
* Symbol#to_proc でメソッド呼び出し元での Refinements が有効になり......IO#readlines, IO.foreach は
chomp というキーワード引数を受け付けるようになりました。12553
* Kernel
* Kernel#clone は freeze というキーワード引数を受け付けるようになりました。
12300
* MatchData
* MatchData#named_captures...