public
Created

  • Download Gist
0_regexp.rb
Ruby
1 2 3 4 5 6 7 8 9 10
# encoding: utf-8
 
re = /[\u{20}-\u{7E}]/
p re, re.encoding, re.source, re.source.encoding
 
re_s = "\u{20}-\u{7E}"
p re_s, re_s.encoding
 
re = /[#{re_s}]/
p re, re.encoding, re.source, re.source.encoding
1_output
1 2 3 4 5 6 7 8 9 10 11 12
$ ruby1.9.3 -v regexp.rb
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin10.8.0]
/[\u{20}-\u{7E}]/
#<Encoding:US-ASCII>
"[\\u{20}-\\u{7E}]"
#<Encoding:US-ASCII>
" -~"
#<Encoding:UTF-8>
/[ -~]/
#<Encoding:US-ASCII>
"[ -~]"
#<Encoding:US-ASCII>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.