From: Tom Allison Date: 2006-10-03T09:01:23+09:00 Subject: regular expressions I'm sorry if this has been done before, but I can't seem to find any good examples: I'm trying to search mail messages for headers based on the following: config = YAML.load_file('config.yaml') $stdin.each do |line| puts line if line =~ /^Recevied:/ .. line =~ /by #{config['hostname']}/o end and guess what? It doesn't work. If I hard code the hostname it works fine. But this and /by config['hostname']/ both fail to match. So, how do you set a variable in a regular expression? Also, how would I match multiple lines? I would much rather match something like: /^Received:.+?\s{4,}by #{config['hostname']}/sm because that will pick up the one Received header I want. I can write in Perl 5 regex but I'm not as familiar with Ruby's methods.