Find a string in a file

i want to find a string in file then retrieve the rest,this is an
exemple of a line:
taske :say_hellow do
i want retrieve just “say_hellow”
so how can i do please.

Should be able to do something like to separate the tasks:

u = open( “myfile” )
while line = u.gets
if line.include?( “taske :” )
anArray = line.split(’ ')
puts anArray[1] if anArray.length > 0

You could even combine the split function with the index function
line,split(’ ')[1] if you are sure where the target info will be.

Note: Don’t be afraid to try different things. This solution is only
one of many and others here could do a lot better. You could do better
with a little practice and research.


After you finish reading that, if you still have questions give a holler
over at the (ruby) forum. This is
more of a ruby question than it is a rails question, unless you can be
more specific as to what type of task within rails you are trying to

Take care.

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