From: "Nik Z." Date: 2011-08-20T05:14:33+09:00 Subject: Re: Searching in a directory or just by changing one line if this helps with your situation: if line =~ /(#{str})(?:.*\1)?/ Yu Yu wrote in post #1017568: > Hello, > I still have problems and need your help! > > I forgot to say that the algorithm should search the next string if the > actual string was found in one .txt file. The reason is that there're > some strings double. > > > This is my code, taken from 7stud: > > dir_path = 'c:/temp' > str = "string" > > Dir.chdir(dir_path) do > > Dir.glob("*.txt") do |filename| > IO.foreach(filename) do |line| > if line =~ /#{str}/ > puts "#{filename}: #{str}" > end > end > end > end -- Posted via http://www.ruby-forum.com/.