Finding keywords in user input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 Answer
+ 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