<SCRIPT LANGUAGE="Javascript">
<!--
function remove_list()
{
var count = 0;
var list = document.form1.list.value;
list =list.replace(/\r/gi, "\n");
list = list.replace(/\n+/gi, "\n");
var listvalues = new Array();
var newlist = new Array();
listvalues = list.split("\n");
var hash = new Object();
for (var i=0; i<listvalues.length; i++)
{
if (hash[listvalues[i].toLowerCase()] != 1)
{
newlist = newlist.concat(listvalues[i]);
hash[listvalues[i].toLowerCase()] = 1
}
else { count++; }
}
document.form1.list.value = newlist.join("\r\n");
}
//-->
</SCRIPT>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<CENTER>
<FORM ACTION="" NAME="form1" ID="form1">
<TABLE BORDER=1 CELLPADDING=5 BORDERCOLOR="#FF0000" BGCOLOR="#FFFFFF">
<TR>
<TD>Paste list to be de-duped here<BR>(one value per line)<P><TEXTAREA NAME="mainlist" COLS=30 ROWS=20></TEXTAREA></TD>
</TR>
<TR><TD align="center"><input type="button" onClick="remove_list();" value="De-Dupe List!"></TD></TR>
</TABLE>
</center>
</FORM>
For Example -:
Input-: Apple,Mango,Apple,Orange
Output -: Apple,Mango,Orange
Showing posts with label remove duplicate words. Show all posts
Showing posts with label remove duplicate words. Show all posts
Remove Duplicate words in javascript
Posted by
Yugant Khokhar
on Monday, May 10, 2010
Labels:
remove duplicate words
/
Comments: (0)