Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Ruby | Regexp | fixed_encoding?

概要

Regexp#fixed_encoding? -> bool

詳細

正規表現が任意の ASCII 互換エンコーディングとマッチ可能な時に false を返却。

サンプルコード
require 'tbpgr_utils'


bulk_puts_eval binding, <<-EOS
/ascii/.fixed_encoding?
/utf-8/u.fixed_encoding?
/ほげ/.fixed_encoding?
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

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

出力

/ascii/.fixed_encoding?  # => false
/utf-8/u.fixed_encoding? # => true
/ほげ/.fixed_encoding?   # => true