m Treat string as multiple lines. That is, change "^" and "$" from matching at only the very start or end of the string to the start or end of any line anywhere within the string, s Treat string as single line. That is, change "." to match any character whatsoever, even a newline, which it normally would not match.