From: Johnathan Smith Date: 2007-12-11T08:42:56+09:00 Subject: printing hi 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 thanks ruby class: File.open('testnew.txt').each do |line| if line =~ /(.*?)\[(.*?)\](.*)/ end puts .txt file - i know it doesnt make any sense uhvbguyfgtyftyf [ref1] jhvbufgytf [ref2, ref1] jhvytfdr [ref2] -- Posted via http://www.ruby-forum.com/.