From: Phrogz Date: 2007-12-11T10:14:58+09:00 Subject: Re: printing On Dec 10, 4:42 pm, Johnathan Smith wrote: > im trying to: > # open a .txt file and read all the lines in the file > # run a regular expression to find in the form of (some text) (then > anything in [])(some text) > # iterate through each line in the file until no references left > > i have achieved the following but i want to print out the references > > im unsure how to do this. > any help would be much appreciated > iv provided my code below > > ruby class: > > File.open('testnew.txt').each do |line| > if line =~ /(.*?)\[(.*?)\](.*)/ > end File.open('testnew.txt').each do |line| if line =~ /(.*?)\[(.*?)\](.*)/ puts line end end