JRS: In article <75***************@storefull-3331.bay.webtv.net>, dated
Fri, 10 Jun 2005 17:35:37, seen in news:comp.lang.javascript, Papajo
<do*****@webtv.net> posted :
I,m looking for a script to remove duplicates email addresses from a
list, the addresses will be displayed one per line in a textarea. The
script will be used on a simple webtv browser. Thanks Joe
I know little of WebTV, but the obvious way would be :-
(1) Tidy the entries, if applicable, by removing such as leading or
trailing whitespace.
(2) Split the textarea at newlines
(3) Sort
(4) Scan, copying to a new list only those differing from their
predecessor.
The following was written in a textarea F.Code (in js-quick.htm), and
eval() was applied to F.Code.value; the result looked as required.
// aaa
// ccc
var Y = [], Last, Z, j, X = F.Code.value.split(/[\r\n]+/).sort()
for (j=0; j<X.length; j++) if (Last!=X[j]) Y[Y.length] = Last = X[j]
// aaa
Y = Y.join("\n")
F.Code.value=Y
Note that the non-comment lines are in alphabetical order, so that the
code does not rearrange itself.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.