From: brabuhr@... Date: 2010-03-22T12:04:32+09:00 Subject: Re: A regexp? On Sun, Mar 21, 2010 at 10:23 PM, Derek Smith wrote: > I am parsing through /var/log/mail.log via regexp and I need to skip > date lines that are NOT followed by to|from|connect.  Here is my code: >... >                ##p(line.chomp.scan(/^(.{15})\s+(\S+)\s+(\S+)\s+(.+)$/).first) >                datestr = (line.chomp.scan(/^.{15}/)) >                mailmsg = > (line.chomp.scan(/^.?connect\sto.*|to=.*|host.*$/)) >... > The output of this code is below and I DO NOT want, can skip the output > such as > Mar 21 18:58:08 > Mar 21 18:58:08 > Mar 21 18:58:08 >... > I only want ouput IF the date is followed by to=|connect\sto.*|host.* I stuck your regex and data in rubular,check it out: http://www.rubular.com/r/zhcQ1lccgp