In article <3DhPa.102688$a51.96868 / news02.bloor.is.net.cable.rogers.com>, mike / ratdog.stok.co.uk (Mike Stok) writes: > It doesn't automatically escape the interpolated thing and that's a good > thing. Sometimes I construct alternations dynamically e.g. > > [mike@ratdog mike]$ irb --simple-prompt >>> words = %w{foo bar baz} > => ["foo", "bar", "baz"] >>> match_a_word = /\b(?:#{words.join('|')})\b/ > => /\b(?:foo|bar|baz)\b/ >>> "April fool" =~ match_a_word > => nil >>> "this has a foo in it" =~ match_a_word > => 11 How about /\b#{Regexp.alt words}\b/ using following Regexp.alt: def Regexp.alt(*args) if args.empty? /(?!)/ else Regexp.compile(args.map {|arg| Regexp === arg ? arg.to_s : Regexp.quote(arg) }.join('|')) end end -- Tanaka Akira