Strench Error

I am new with ruby but something fishy with the array.
if I type
q=aa
puts INV_FILE_HASH[q] # where INV_FILE_HASH is my hash function
I GET THE RESULT PERFECTLY HOWEVER,
query is user input and couldbe ‘aa’ or ‘aa aa’
query = query.split(/ /)
query.each { |q|
if (q == ‘and’)
OP.push(‘and’)
elsif (q == ‘or’)
OP.push(‘or’)
else
# q=aa at this point which is correct
puts INV_FILE_HASH[q] # prints out nil instead of values
end
}

I get “nil” where the query is ‘aa’ so the q is ‘aa’.
but if the query is ‘aa aa’ than q first run is ‘aa’ and second run is
‘aa’ in first run it prints the result out but on second run the result
is ‘nil’ again. I can run 1000 run the first 999 is correct but 1000th
run is nil again. what does realy cause this?

I found it, it was
query = query.split(/ /)
some reason when I change to
query = query.scan(/\w+/)
it worked HOWEVER
THIS TIME IT IGNORES MY PHARANTESIS, how can I scan so that it would
take the pharanthesis as another piece of string ?
thank you