るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
5件ヒット [1-5件を表示] (0.022秒)
トップページ > バージョン:2.6.0[x] > クエリ:nil[x] > クエリ:DATA[x] > 種類:変数[x]

別のキーワード

  1. _builtin nil?
  2. nilclass nil?
  3. object nil?
  4. _builtin nil
  5. object nil

ライブラリ

モジュール

キーワード

検索結果

Kernel$$~ -> MatchData | nil (643.0)

現在のスコープで最後に成功したマッチに関する MatchDataオブジェクトです。 Regexp.last_match の別名です。

現在のスコープで最後に成功したマッチに関する MatchDataオブジェクトです。
Regexp.last_match の別名です。

このデータから n 番目のマッチ ($n) を取り出すためには $~[n] を使います。

この値に代入すると Regexp.last_match や、 $&, $1, $2, ... などの関連する組み込み変数の値が変化します。
MatchData オブジェクトでも nil でもない値を代入しようとすると TypeError が発生します。

この変数はローカルスコープかつスレッドローカルです。
Ruby起動時の初期値は nil です。

//emlist...

Kernel$$LAST_MATCH_INFO -> MatchData | nil (625.0)

$~ の別名

$~ の別名

require "English"

str = "<a href=https://www.ruby-lang.org/en/about/license.txt>license</a>"

if /<a href=(.+?)>/ =~ str
p $LAST_MATCH_INFO[0] #=> "<a href=https://www.ruby-lang.org/en/about/license.txt>"
p $LAST_MATCH_INFO[1] #=> "https://www.ruby-lang.org/en/about/license.t...

Kernel$$INPUT_RECORD_SEPARATOR -> String | nil (328.0)

$/ の別名

$/ の別名

require "English"

$INPUT_RECORD_SEPARATOR = '|'
array = []
while line = DATA.gets
array << line
end
p array #=> ["ugo|", "ego|", "fogo\n"]

__END__
ugo|ego|fogo

Kernel$$RS -> String | nil (328.0)

$/ の別名

$/ の別名

require "English"

$INPUT_RECORD_SEPARATOR = '|'
array = []
while line = DATA.gets
array << line
end
p array #=> ["ugo|", "ego|", "fogo\n"]

__END__
ugo|ego|fogo

Kernel$$LAST_PAREN_MATCH -> String | nil (325.0)

$+ の別名

$+ の別名

require "English"

r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")

while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikkou</td>...

絞り込み条件を変える