How to remove duplicate words from text

Giganews Newsgroups
Subject: How to remove duplicate words from text
Posted by:  carlit…@websurfer.co.za (Voetleuce en fênsievry)
Date: 22 Jul 2003

Hello everyone.

I'm not a JavaScript author myself, but I'm looking for a method to
remove duplicate words from a piece of text.  This text would
presumably be pasted into a text box.

I have, for example, a list of town names, but there are hundreds of
duplicates, like:

"Aberdeen Aberdeen Aberdeen Edinburg Edinburg Inverness etc."

Can you direct me to a script (or write one, please) that will remove
the excess names and leave just one instance of each name, like:

"Aberdeen Edinburg Inverness etc."

Thanks in advance!
[E-mail answers appreciated, but I'll also check the newsgroup.]

Replies