以前に正規表現の一致に gsub を使用しましたが、文字列リテラルには何を呼び出す必要がありますか?
ファイル内のpair[0]
どこにpair[1]
でも置き換えたい。pair[0]
text = File.read( fname )
@hash_old_to_new.each do
|pair|
puts "\tReplacing " + pair[0] + " with " + pair[1]
# result = text.gsub( /pair[0]/, pair[1] ) <--- this is no good
end
File.open( fname, "w" ) { |file| file << result }