2006-12-11 String#[]に正規表現を渡す Rubyでは、String#[]に正規表現を渡すと、マッチした部分文字列を返します。 s = "We wish you a Merry Christmas!" p s[/C\w+mas/] #=> "Christmas"