Caleb Clausen wrote:
> On 10/12/09, Collin Moore <collin.moore / gmail.com> wrote:
>> : just for easy import into excel.
>> end
>>
>> Any ideas?
> 
> You want a regexp. Something like this should work. (Stick it in
> before the puts line.) (You may need to customize depending on your
> exact requirements.)
> 
> line.sub!(/^Time@ (\d+\.\d+):.*\*{3} ([A-Z]+ [A-Z]+) \*{3}$/){ $1+':'+$2 
> }

I tried this with

File.open('output.txt', 'w') do |f2|
File.readlines("original.txt").each do |line|
 if line =~ /DEBUG/ || line =~ /START/
    f2.puts line.sub!(/^Time@ (\d+\.\d+):.*\*{3} ([A-Z]+ [A-Z]+) 
\*{3}$/){ $1+':'+$2 }
        end

  end
end

and I get the output.txt with nil for each positive match.
-- 
Posted via http://www.ruby-forum.com/.