2009-10-12 任意の文字列の正規表現をまとめてつくる ruby a = %w(banana orange apple) #=> ["banana", "orange", "apple"] r = Regexp.union(a.map{|e| /\A#{Regexp.escape(e)}\z/}) #=> /(?-mix:\Abanana\z)|(?-mix:\Aorange\z)|(?-mix:\Aapple\z)/ "apple" =~ r #=> 0 "bananana" =~ r #=> nil