#! ruby -Ku require "kconv" def check1(str) if /Red(?=Color)/ =~ str then print(Kconv.tosjis("○") + str + "(" + $& + ")\n") else print(Kconv.tosjis("×") + str + "\n") end end def check2(str) if /Red(Color)/ =~ str then print(Kconv.tosjis("○") + str + "(" + $& + ")\n") else print(Kconv.tosjis("×") + str + "\n") end end def check3(str) if /(?=Red)Color/ =~ str then print(Kconv.tosjis("○") + str + "(" + $& + ")\n") else print(Kconv.tosjis("×") + str + "\n") end end print(Kconv.tosjis("/Red(?=Color)/ にマッチするかどうか\n")) check1("RedColor") print("\n") print(Kconv.tosjis("/Red(Color)/ にマッチするかどうか\n")) check2("RedColor") print("\n") print(Kconv.tosjis("/(?=Red)Color/ にマッチするかどうか\n")) check3("RedColor")