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]

On Dec 10, 4:42 pm, Johnathan S. [email protected] wrote:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs