title: How to match regex over multiple lines
body: <p>I have a body of text and I am trying to find a character sequence within it. <code>String.contains()</code> will not work so Im trying to use <code>String.matches</code> method and a regular expression. My current regex isn't working. Here are my attempts:</p>
  
  <pre><code>"1stline\r\n2ndline".matches("(?im)^1stline$"); 
  // returns false; I expect true
  
  "1stline\r\n2ndline".matches("(?im)^1stline$") 
  // returns false
  
  "1stline\r\n2ndline\r\n3rdline".matches("(?im)^2ndline$")   
  
  "1stline\n2ndline\n3rdline".matches("(?im)^2ndline$")
  
  "1stline\n2ndline\n3rdline".matches("(?id)^2ndline$")
  </code></pre>
  
  <p>How should i format my regex so that it returns true?</p>