概要
Regexp#options -> Integer
詳細
規表現の生成時に指定されたオプションを返却。
戻り値は Regexp::EXTENDED, Regexp::IGNORECASE, Regexp::MULTILINE, Regexp::FIXEDENCODING, Regexp::NOENCODING, の論理和。
サンプルコード
require 'tbpgr_utils' bulk_puts_eval binding, <<-EOS Regexp.new("h.ge").options Regexp.new("h.ge", Regexp::IGNORECASE).options Regexp.new("h.ge", Regexp::IGNORECASE | Regexp::MULTILINE).options /h.ge/.options /h.ge/i.options /h.ge/mi.options EOS __END__ 下記はTbpgrUtils gemの機能 bulk_puts_eval https://rubygems.org/gems/tbpgr_utils https://github.com/tbpgr/tbpgr_utils
出力
Regexp.new("h.ge").options # => 0 Regexp.new("h.ge", Regexp::IGNORECASE).options # => 1 Regexp.new("h.ge", Regexp::IGNORECASE | Regexp::MULTILINE).options # => 5 /h.ge/.options # => 0 /h.ge/i.options # => 1 /h.ge/mi.options # => 5