From: x1 Date: 2006-09-26T10:27:11+09:00 Subject: Regexp Question / gsub Question Perhaps someone could help with this example? I need to iterate through each of the items in strings and wrap any case insensitive occurrence of "key" with . If each string was always just the word "key" I would use something like wrapper.join("key") but.. I have other text surrounding the "key", various cases and potentially multiple occurrences. Thank you in advance. wrapper = ["", ""] strings = ["blahblahKEY", "asdfasdfkey", "Keyasdf", "xxkEYxx", "xxKeyxxKEY"] strings.each do |string| # would like to print the string replacing "key" (case insensitive) with "key"(in its original case) end # Ideally, would output: # "blahblahKEY" # "asdfasdfkey" # "Keyasdf" # "xxkEYxx" # "xxKeyxxKEY"