From: Robert Klemme Date: 2003-12-03T21:12:05+09:00 Subject: Re: Please recommend a regular expression excluding return character... "Kurt Euler" schrieb im Newsbeitrag news:C47CCC6238EFD4119C5200508B95A10010B7F19D@cup1ex1.portal.com... > All- > > Can anyone recommend a regular expression that excludes the return > character? > > My objective is to find occurances of a string WITHIN A LINE of a text > file. Thus, if givein some_string1 and some_string2, match: > > > > > Thanks! > > Kurt Euler If you use readline or gets you don't even need to bother with the newlines: File.open("file.txt", "r") do |f| while ( line = f.gets ) line.chomp! if /my_regexp/ =~ line puts "Found it!" end end end Otherwise omitting the /m flag at the regexp avoids "." to match the newline. Regards robert