From: Dan Zwell Date: 2007-08-01T06:14:27+09:00 Subject: Re: help with string matching Dan Daniels wrote: > Dan Zwell wrote: >> Dan Daniels wrote: >>> end >>> end >>> end >>> >>> >>> >>> Any ideas or hints appreciated! >>> Dan >> What is logdatepattern, and what is its relation to logdate? > > Apologies, I tried to pear down the post and left that out accidentally. > > I had also tried: > > logdatepattern = logdate > > and > > logdatepattern = logdate.to_s > > Here is the original post, fixed: > > This does not work: > > logdate = "#{@calendar1.year}-" + (@calendar1.month + 1).to_s + > "-#{@calendar1.day}" > > puts "Getting log for #{logdate}" > File.open("rdpconnect.log").each do |line| > if line.match(logdate) > puts line > end > end > > > However, this does: > > logdate = "2007-07-30" > puts "Getting log for #{logdate}" > File.open("rdpconnect.log").each do |line| > if line.match(logdate) > puts line > end > end > > > The format of logdate appears the same in both instances. What am I > missing? > > Thanks, I don't know what @calendar1 is, so I can't reproduce this, but I thought what Nobu meant when he replied to you is to say that the value of that line contains 3 zeros, while the string you fed it contains 4. Dan