[Rails] Re: find a string in a file
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
end
end
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.
On Jun 5, 7:08 pm, Adel Mediouni <mediouni.a...@gmail.com> wrote:
> hi
> 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.
> thanks.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home