From: "Marcin Mielżyński" Date: 2006-09-15T09:10:50+09:00 Subject: Re: Newbie regexp question James Calivar wrote: > Hello, > > I'm trying to split a formatted text file into four separate columns. > The data is comprised of lines of text that are bundled into four > distinct columns, corresponding to a "Required versus Optional" > variable, a requirement number, a requirement classification (R1=Rev 1, > F=Future, I=Internal), and a textual description of the requirement. > > My raw data looks like this in the input text file: > > R [01] R1 The system shall support "emergency call processing" > R [02] R1 The system shall support "local call processing" > R [08] F The system shall provide a command-line user interface > R [723] F The system shall provide 6 10/100/1000 Ethernet interfaces > R [11] F The system shall support VoIP networks > R [398] R1 The system shall contain 2 control boards > O [327] I The system should support hotswapping of all internal boards > R [19] I The system shall be able to detect transmission errors > R [631] F The system shall continue processing data as long as a call is > active. > try this one open("file").read.scan(/(\w)\s+(.+?)\s+(\w+)\s+(.*?)\n?$/){|req,num,cls,dsc| ...} lopex