るりまサーチ (Ruby 2.5.0)

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

別のキーワード

  1. ripper warning
  2. syslog warning
  3. rubygems/user_interaction alert_warning
  4. warning warn
  5. testtask warning

検索結果

Regexp#~ -> Integer | nil (28.0)

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

...hoge"

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
puts "no match"
end
# => no match

if reg
puts "match"
else
puts "no match"
end
# => match...