This is what I've been trying, but something is wrong with the last part, can sy please tell me whats wrong, or show me an other method of doing this. Thanks in advance.
function removeSpaces(string) {
var str = string.replace(/^\s*|\s*$/g,'')
str = str.replace(/[^a-z|A-z|\r\n]/g,'');
while (str.indexOf("\r\n\r\n") >= 0) {
str = str.replace(/\r\n\r\n/g, "\r\n");
}
words = str.split("\r\n");
var i = 0;
var j = 0;
for (i = 0; i < words.length; i++) {
for (j = i; j < words.length; j++) {
if ((i != j) && (words[i] == words[j])) {
words.splice(j,1);
j--;
}
}
}
str = words.join("\r\n");
return str;
}