Al Cholic wrote: > Hello, > > I have a file that includes a "---------" string at a certain line > number. How can I find out at which line number the string occurs? > Would it be best to split the text file into an array with split("\n") > and then use a for loop or is there some other hidden methods in ruby? > > Basically I want to start reading a text file after the "---------" line > that appears in it. > > Can someone help please? > > Thanks in advance. 2 methods come to my mind to do that: 1) as you said, split and find what index in the array contains the line 2) get the offset (String#index) of the first "---------", count the "\n"s in the substring 0,offset. I'd assume that the second is faster. Regards Stefan -- Posted via http://www.ruby-forum.com/.