array
, and then capture the index of the word, so alright I can get the word index , but I need to go through all array
and if I have the word repeated, I need to save all indexes of that word.
Test.txt file:
a; b; c; a; d; a
Code:
file = File.open('teste.txt')
#fazendo um For Linha a Linha
file.each_line do |line|
#Separando as palavras e convertendo para string
values = line.split(';').to_s()
#capturando o index da palavra que seja igual a 'a'
#idExc = Array[]
idExc = values.index(/a/)
puts values[idExc]
end
It is only capturing the first position, but I have the letter a
repeated, I need to save all indexes referring to a
.
Anyone know how to do this?