Ruby on Rails Monday, December 1, 2014

Hi again

" Isolate the area with the text you want " , example ? 

This is how: 
def read_file(file_name)
  temp = File.open(file_name, "r").read
  data = temp.split("\n")
  lookup_item = temp.match(/\tSystem Information/)
  puts lookup_item.to_s + " <------lookup item"
  @my_match = data.index(lookup_item.to_s)
  puts data[@my_match + 1]
  puts data[@my_match + 2]
  return @my_match  
end

puts "Start"
puts read_file("./test_info.txt")
puts "End" 

Ideally it looks like you have to grab a book of regular expressions. 
It was the first thing I did :D


Now I need to find a way to use this^, in my rails project :D 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fc20b136-1766-417c-acb2-97ca64fa1a28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment