This looks like an XML string. Did course_info come from an XML
document? An XML parser like Hpricot or Nokogiri would be an
improvement.
Quick update:
Just installed and followed a quick tutorial on Hpricot.
While effectively accomplishing the same task, this parser makes the
code much easier to read. I can now write:
doc = Hpricot.parse(File.read(“courses.xml”))
(doc/:course).each do |course|
if (course/:date).inner_html.match “#{date}”
groups_that_had_lessons_this_month << (course/:title).inner_html
end
end
as opposed to this (or worse):
File.open(“courses.txt”, ‘r’) do |datei|
datei.readlines.select do |line|
if line.match “#{date}”
groups_that_had_lessons_this_month << line[ /([^<]+)/, 1 ]
end
end
end
Thanks for the recommendation, and thanks everyone else for the answers
too.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.