From: ts Date: 2000-11-19T01:57:42+09:00 Subject: [ruby-talk:6440] Re: variable in regular expression >>>>> "m" == markus jais writes: m> old = ARGV[1] m> new = ARGV[2] This is the same than perl (it begin at 0) old = ARGV[0] new = ARGV[1] m> dir = Dir.new("."); m> while line = dir.read m> next if line == "." or line == ".." m> puts line m> line.sub!(/old/, new) #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Error You must write /#{old}/ to expand the variable 'old' otherwise ruby think that it's the string "old" m> puts line m> end Guy Decoux