From: Siep Korteling Date: 2008-10-25T07:05:59+09:00 Subject: Re: help with regular expressions Vandana wrote: > Hi all, > > I'm fairly new to programming with regular expressions. I would like > some help with the > following. Consider the format given below as what I will receive in a > file. > > While reading from the file, Im interested only in reading those lines > that have the forward-slash' in > them (lines 9,10,12, 13). How can I do this in ruby? (...) 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. hth, Siep -- Posted via http://www.ruby-forum.com/.