From: 7stud -- Date: 2008-03-26T15:49:25+09:00 Subject: Re: sorting text in a file 7stud -- wrote: > Adam Akhtar wrote: >> The details are a bit trickier as some spill onto a second line (but >> seperated by a blank line). > > Then you should have posted an example file with all the possibilities. > >> Second am i going about this the write way. S >> > > Probably not. > >> Should I have just avoided >> regex and simply read the file line by line using if structures to >> figure out which lines are with which event??? >> > > That is one way. On the website, the information is probably contained > in different html tags. So scraping the website, then joining all the > data together, then trying to separate the data is not a good plan. > You should be able to pick the pieces from the website directly. > However, you have to know html is written and how it is structured. > Ruby has several gems, e.g. Hpricot, that make it easy to pick out > pieces of information on a website, but you sort of have to know how > html in order to pick out the data you want. > > If that sounds too confusing, then just deal with the text file you > have, and YES you should avoid regex's whenever possible. So reading > the file line by line would be much easier. Ack! Let's try that again: That is one way. On the website, the data is probably contained in different html tags. So scraping the website, then joining all the data together, then trying to separate the data back out again is not a very good plan. You should be able to pick out the pieces of the data you want directly from the html. However, you have to know how html is written and how html is structured. Ruby has several gems, e.g. Hpricot, that make it easy to pick out pieces of information from a page of html. If that sounds too confusing, then just deal with the text file you have already, and YES you should avoid regex's whenever possible. Reading the file line by line would be better and probably easier. -- Posted via http://www.ruby-forum.com/.