From: Leslie Viljoen Date: 2006-10-03T22:37:52+09:00 Subject: Re: regular expressions On 10/3/06, Tom Allison wrote: > 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. To eliminate a possibility, do p config['hostname'] just before the $stdin line there. I can't tell you how many times I have forgotten about invisible newlines tacked onto my variables that cause all sorts of matching to fail. Les