以下の内容はhttps://tbpgr.hatenablog.com/entry/20141119/1416404940より取得しました。


Ruby | Regexp | == / eql?

概要

Regexp#self == other -> bool
Regexp#eql?(other) -> bool

詳細

otherが同じパターン、オプション、文字コード正規表現であったらtrueを返却。

サンプルコード
require 'tbpgr_utils'


bulk_puts_eval binding, <<-EOS
/h.ge/ == /h.ge/
/h.ge/ == Regexp.compile(/h.ge/)
/h.ge/ == /h.ge/i
/(?-mix:hoge)|(?-mix:hige)/ == Regexp.union(/hoge/, /hige/)
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils

出力

/h.ge/ == /h.ge/                                            # => true
/h.ge/ == Regexp.compile(/h.ge/)                            # => true
/h.ge/ == /h.ge/i                                           # => false
/(?-mix:hoge)|(?-mix:hige)/ == Regexp.union(/hoge/, /hige/) # => true



以上の内容はhttps://tbpgr.hatenablog.com/entry/20141119/1416404940より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14