From: Lee Jarvis Date: 2007-12-06T22:17:22+09:00 Subject: Re: if /hello/ =~line Jano Svitok wrote: > (This might apply for 1.8 MRI only, other interpreters might be > different): When the regex literal contains #{}, the object > is created on each pass through the code. In the other case it's > created only once. True, you could use the Regexp class also then.. var = 'hello' revar = Regexp.new(var) if revar =~ line #.. end or perhaps var = 'hello' File.foreach 'file.txt' do |line| if Regexp.new(var) =~ line puts 'found it' break end end If you don't care how many times its created and you don't want to use the '#' in your regexp matches because your IDE doesn't know any better. Regards, Lee -- Posted via http://www.ruby-forum.com/.