title: remove duplicate lines with regex in javascript
body: <p>According to <a href="http://www.regular-expressions.info/duplicatelines.html" rel="nofollow">regular-expressions.info</a>, I should be able to remove duplicate lines (as long as they are consecutive) with the following pattern: <code>^(.*)(\r?\n\1)+$</code></p>
  
  <p>This is pretty straightforward within Notepad++, I just hit "Replace all" with <code>\1</code> and all the duplicates are removed. However, I cannot get it to work with javascript when pulling text from a <code>&lt;textarea&gt;</code>.  </p>
  
  <pre><code>var t = $("#input").val();
  var re = /^(.*)(\r?\n\1)+$/g;
  var s = t.replace(re, "$1");
  console.log(s);
  </code></pre>
  
  <p>Why has adding the <code>g</code> flag not removed all of the duplicate lines?</p>