"Swap" Function

<SCRIPT>

var str = prompt("Please enter 3 words:", "I see you");

if (str == "" || str == null) str = "I see you";

// "reverse" the order by "swapping" the words
str = str.
replace(/(\w+) *(\w+) *(\w+)/, "$3 $2 $1");

OR

str = str.replace(/(\w+)\s(\w+)\s(\w+)/, "$3 $2 $1");

alert(str);

document.write(str);

</SCRIPT>