#! ruby -Ku require "kconv" def check1(str) if /(s_)(.+)(_e)/ =~ str then print(Kconv.tosjis("○") + str + "\n") print(" [" + $1 + "]\n") print(" [" + $2 + "]\n") print(" [" + $3 + "]\n") else print(Kconv.tosjis("×") + str + "\n") end end def check2(str) if /(s_)(?:.+)(_e)/ =~ str then print(Kconv.tosjis("○") + str + "\n") print(" [" + $1 + "]\n") print(" [" + $2 + "]\n") else print(Kconv.tosjis("×") + str + "\n") end end print(Kconv.tosjis("(s_)(.+)(_e) にマッチするかどうか\n\n")) check1("s_END_LINE_e") print("\n") print(Kconv.tosjis("(s_)(?:.+)(_e) にマッチするかどうか\n\n")) check2("s_END_LINE_e")