Finding keywords in user input? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Finding keywords in user input?

I'm looking to see if there is a way to find certain keywords in user input, such as "look" in the input "look around."

18th Apr 2017, 11:24 PM
Chris L.
1 Réponse
+ 1
I don't know Ruby, but have you considered splitting the input into individual words and iterating thru them looking for specific keywords? yourString = "hey you, look over here" yourString=yourString.split(' ') yourString.each { |x| puts "looked" if x == "look"}
19th Apr 2017, 10:30 AM
LordHill
LordHill - avatar