Similar to $, the shortcut \z matches the end of a string, not a line
opening = "This is a test. This is a test. \nThis is a test. This is a test. ,\n" opening.grep(/this is,\z/)