MonkeeSage wrote:
> Tom Allison wrote:
>> So, how do you set a variable in a regular expression?
> 
> You have it right.
> 
>> Also, how would I match multiple lines?
> 
> You're right again with the //m. But you can't read line-by-line
> (IO#each) and match across multiple lines without building some kind of
> parser. It's usually better to just read the data into a single string
> for multiline matches.
> 
> Input (multiline):
> Received: from mail.papa.smurf (mail.papa.smurf [127.0.0.1])
> by down / fraggle.roc
> 
> config = {'hostname' => 'down / fraggle.roc'}
> line = $stdin.read
> puts line if line =~ /^Received:.*by #{config['hostname']}/m
> 

This prints out the entire message.

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.

But the match on /Received/ turns on the printing and it never matches on the 
second regexp.