
|
<SCRIPT> str = prompt("Please Enter your Name (First Last):", "Frank Peter"); if (str == "" || str == null) str = "Frank Peter"; str = str.replace(/(\w+)\s(\w+)/, "$2, $1"); // "swap" the 1st word and the 2nd word alert(str); document.write(str); </SCRIPT> |