# Similarly to ^, the shortcut \A matches the beginning of a string opening = "This is a test. \nThis is a test. This is a test. ,\n" opening.grep(/\Athis in/)