看板 Ruby 關於我們 聯絡資訊
※ 引述《godspeedlee (godspeed lee)》之銘言: : 1.9.2 感覺要寫更多 code ...0rz 我想多少不是問題,能不能用和好不好用比較重要 :p : 各位有辦法把下面的 code 變短嗎?不過 1.8.7 的 regex engine 實在很弱 : (PCRE都比他強),看來還是得切換到 1.9.2... : # "\xB4\xFA\xB8\xD5" = "測試" : s = "\xB4\xFA\xB8\xD5".force_encoding("big5-uao") : re = Regexp.new('[\xA1\x40-\xF9\xF0]'.encode(s.encoding)) : if s =~ re : puts("test ok!") : end 你不介意的話可以把整個 source code 當成 big5-uao XD 就在檔案最前面加上 # encoding: big5-uao 即可 或是試試設定 Encoding.default_internal 和 Encoding.default_external -- 「行け!Loki!」(rocky ロッキー) -Gurumin ぐるみん 王子? XD -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.160.129