printing

J

Johnathan Smith

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]
 
P

Phrogz

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top