From: Glenn Jackman Date: 2010-04-09T01:30:08+09:00 Subject: Re: simple text parsing At 2010-04-08 10:44AM, "Remington Splettstoesser" wrote: > Hello Everyone, > > What is the best way to get this input > > test.txt > ------------------------------------------------ > David | Hansson | Chicago > Obie | Fernandez | Jacksonville > ------------------------------------------------ > > to this output: > > First Name: David > Last Name: Hansson > City: Chicago > > First Name: Obie > Last Name: Fernandez > City: Jacksonville Looks like you have a specific field separator, so might as well use it: print_format = "First Name: %s\nLast Name: %s\nCity: %s\n\n" File.foreach("test.txt") do |line| first, last, city = line.chomp.split(/ \| /) print print_format % [first, last, city] end -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous