If you want to support variables instead of "Foo" and "Bar", use:
/Hi my name is (\w+)\s*and I live in (\w+)/
As seen on rubular .
It also puts "Foo" and "Bar" (or any line contained) in capture groups, which you can subsequently use.
str = IO.read('file1.txt')
match = str.match(/Hi my name is (\w+)\s*and I live in (\w+)/)
puts match[1] + ' lives in ' + match[2]
It will be printed:
Foo lives in a bar