Q:

How to tell if a string contains a substring

I want to know if a string contains a substring.
String examples:
"Hey boy, the cat is in the kitchen ?"
"I want to know if the dog is in the kitchen"

Substring:
"the ... is in the kitchen"

But I need to ignore the words "cat, dog", how can I do that?
string.include? is not the right way because I want the complete sentence with "the" at the beginning.

A:

def the_in_the_kitchen(string)
    return string.match?(/the \w+ is in the kitchen/i)
end

This should work. I've used a regexp, and replace the word cat or dog by \w+, which means a serie of letters. I've also added the i flag to the regexp, it stands for ignore case. Hence The DOG iS In ThE KITchen would work as well.

