Tbpgr Blog

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

Ruby | Regexp | encoding

概要

Regexp#encoding -> Encoding

詳細

正規表現オブジェクトのエンコーディングを表す Encoding オブジェクト を返却。

サンプルコード
require 'tbpgr_utils'

bulk_puts_eval binding, <<-EOS
/h.ge/.encoding
/h.ge/u.encoding
/ほげ/.encoding
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

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

出力

/h.ge/.encoding                                # => #<Encoding:US-ASCII>
/h.ge/u.encoding                               # => #<Encoding:UTF-8>
/ほげ/.encoding                                # => #<Encoding:UTF-8>