るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.225秒)
トップページ > ライブラリ:ビルトイン[x] > クエリ:_builtin[x] > クエリ:self[x] > クラス:Regexp[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

検索結果

Regexp#~ -> Integer | nil (8009.0)

変数 $_ の値との間でのマッチをとります。

...以下と同じ意味です。

//emlist[][ruby]{
self
=~ $_
//}

//emlist[例][ruby]{
$_ = "hogehoge"

if /foo/
puts "match"
else
puts "no match"
end
# => no match
# ただし、警告がでる。warning: regex literal in condition

reg = Regexp.compile("foo")

if ~ reg
puts "match"
else...