From: MonkeeSage Date: 2006-10-03T10:20:11+09:00 Subject: Re: regular expressions Tom Allison wrote: > I'm only trying to get the one section that matched the Received header. > I should be able to do with with the statement > puts line if line =~ /Received/ .. line =~ /#{config['hostname']}/ > At least that's what I'm believe I'm being led towards. In ruby .. is a range operator. If you want a grouped match, use parens and a backreference just like perl. $stdin.each { |line| puts $1 if line =~ /^Received:(.+?)\s{4,}by #{config['hostname']}/ # prints " from mail.papa.smurf (mail.papa.smurf [127.0.0.1])" } Regards, Jordan