On Fri, Oct 24, 2008 at 6:12 PM, Craig Demyanovich
<cdemyanovich / gmail.com> wrote:
> On Fri, Oct 24, 2008 at 6:05 PM, Siep Korteling <s.korteling / gmail.com>wrote:
>
>> You don't need a regular expression for this. To select the lines which
>> include a slash, you can do
>>
>> file = File.new( 'D:/1.txt' )
>> slashlines = file.select {|line| line.include?( '/' )}
>> file.close
>> puts slashlines
>>
>>
>> The select method will read each line and put each line for which the
>> block is true in an array.
>
>
> Siep, I can't find any documentation on File#select, and IO#select is not
> documented as doing what you show. Could you provide more info about it?

I couldn't find it explicitly in the docks either, but if you do
File.ancestors, you will see that Enumerable is in there.

To the OP, you could also do (for regex)...

slashlines = my_file.select {|line| line =~ /\//}


Todd