title: How to use JavaScript regex over multiple lines?
body: <pre><code>var ss= "&lt;pre&gt;aaaa\nbbb\nccc&lt;/pre&gt;ddd";
  var arr= ss.match( /&lt;pre.*?&lt;\/pre&gt;/gm );
  alert(arr);     // null
  </code></pre>
  
  <p>I'd want the PRE block be picked up, even though it spans over newline characters. I thought the 'm' flag does it. Does not.</p>
  
  <p>Found the answer <a href="http://blog.simonwillison.net/post/57956777104/newlines" rel="noreferrer">here</a> before posting. SInce I thought I knew JavaScript (read three books, worked hours) and there wasn't an existing solution at SO, I'll dare to post anyways. <strong>throw stones here</strong></p>
  
  <p>So the solution is:</p>
  
  <pre><code>var ss= "&lt;pre&gt;aaaa\nbbb\nccc&lt;/pre&gt;ddd";
  var arr= ss.match( /&lt;pre[\s\S]*?&lt;\/pre&gt;/gm );
  alert(arr);     // &lt;pre&gt;...&lt;/pre&gt; :)
  </code></pre>
  
  <p>Does anyone have a less cryptic way?</p>
  
  <p>Edit: <a href="https://stackoverflow.com/questions/1387116/matching-multiline-patterns">this</a> is a duplicate but since it's harder to find than mine, I don't remove.</p>
  
  <p>It proposes <code>[^]</code> as a "multiline dot". What I still don't understand is why <code>[.\n]</code> does not work. Guess this is one of the sad parts of JavaScript..</p>