Rubyについて Part 36
■ このスレッドは過去ログ倉庫に格納されています
0573デフォルトの名無しさん
2009/07/31(金) 12:45:30# -*- coding: utf-8 -*-
require 'open-uri'
uri = "http://pc12.2ch.net/test/read.cgi/tech/1246174168/571n"
html = open(uri).read
p /#{"表".encode(Encoding::SJIS)}/ =~ html rescue puts $!
p /#{"表".encode(Encoding::SJIS).force_encoding(Encoding::ASCII_8BIT)}/ =~ html rescue puts $!
p /#{"表".encode(Encoding::SJIS)}/ =~ html.dup.force_encoding(Encoding::SJIS) rescue puts $!
動作しそうな記述のうちで実際にマッチするのは最後だけというのがなんとも
incompatible encoding regexp match (Shift_JIS regexp with ASCII-8BIT string)
too short escape sequence
1732
■ このスレッドは過去ログ倉庫に格納されています