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