#! ruby -Ku require "kconv" def check1(str) if /[一-龠]+/u =~ str then print(Kconv.tosjis("○" + str + "(" + $& + ")\n")) else print(Kconv.tosjis("×" + str + "\n")) end end def check2(str) if /[ぁ-んァ-ヴ]+/u =~ str then print(Kconv.tosjis("○" + str + "(" + $& + ")\n")) else print(Kconv.tosjis("×" + str + "\n")) end end print(Kconv.tosjis("/[一-龠]/u にマッチするかどうか\n\n")) check1("明日は雨です") check1("こんにちは。") check1("新年のカレンダー") print("\n") print(Kconv.tosjis("/[ぁ-んァ-ヴ]/u にマッチするかどうか\n\n")) check2("明日は雨です") check2("こんにちは。") check2("新年のカレンダー")