title: JavaScript regex multiline text between two tags
body: <p>I wrote a regex to fetch string from HTML, but it seems the multiline flag doesn't work.</p>
  
  <p>This is my pattern and I want to get the text in <code>h1</code> tag.</p>
  
  <pre><code>var pattern= /&lt;div class="box-content-5"&gt;.*&lt;h1&gt;([^&lt;]+?)&lt;\/h1&gt;/mi
  m = html.search(pattern);
  return m[1];
  </code></pre>
  
  <p>I created a string to test it. When the string contains "\n", the result is always null. If I removed all the "\n"s, it gave me the right result, no matter with or without the <code>/m</code> flag.</p>
  
  <p>What's wrong with my regex?</p>