Sigh, You may all appreciate this code which I've built.
Use it as it is or split it up in to functions and use seperately. You WILL come in to problems with the messages output by the status window but after running through the maze of nested functions that is, nfc chat you should be able to make some use of it. UBB Is useful too:

tempmsg = "";
tempmsg = input;
input = "";
htmlfound = 0;
// Remove blasted Ampersands
tempmsg = tempmsg.replace("&", "and");
//
//
// STRIP OUT FUCK OR BUGGER
// Check for and remove swearing
//
//
arrSwearList = new Array("naughtyword1", "naughtyword2", "naughtyword3");
i = 0;
swearing = 0;
checkswear = tempmsg.toLowerCase();
while (i<arrSwearList.length) {
    ii = 0;
    swearword = checkswear.indexOf(arrSwearList[i], [0]);
    if (swearword != undefined) {
        if (swearword != -1) {
            swearing = 1;
            noOfAst = 0;
            ast = "";
            noOfAst = arrSwearList[i].length;
            while (ii<noOfAst) {
                ast = ast+"*";
                ii++;
            }
            checkswear = checkswear.replace(arrSwearList[i], ast);
        }
    }
    i++;
    if ((swearing == 1) && (i == arrSwearList.length)) {
        tempmsg = checkswear;
    }
}
//
//                                                           
// STRIP OUT ANY HTML
// Check for and remove any html
//                                                   
//
htmlGT = tempmsg.indexOf(">", [0]);
htmlLT = tempmsg.indexOf("<", [0]);
if ((htmlGT != undefined) || (htmlLT != undefined)) {
    if ((htmlGT != -1) || (htmlLT != -1)) {
        // < or >'s detected
        if ((htmlGT != -1) && (htmlLT != -1)) {
            // Both are present
            if (htmlLT<htmlGT) {
                // < comes before >
                //delthis = tempmsg.substring(htmlLT, htmlGT+1);
                //tempmsg = tempmsg.remove(delthis);
                htmlfound = 1;
            }
        }
        tempmsg = tempmsg.remove(">");
        tempmsg = tempmsg.remove("<");
        tempmsg = tempmsg+"<i> - please do not use &lt; or &gt; symbols</i>";
        if (htmlfound == 1) {
            tempmsg = tempmsg+"<i> - html not supported</i>";
        }
    }
}
//
//
// RECODE ANY UBB
// Check for and replace UBB with correct html
//
//
// Detect ubb tags
ubbBold1 = tempmsg.indexOf("[b]", [0]);
ubbBold2 = tempmsg.indexOf("[/b]", [0]);
// Configure bold
if ((ubbBold1 != undefined) && (ubbBold2 != undefined)) {
    if ((ubbBold1 != -1) && (ubbBold2 != -1)) {
        // [b] and [/b] detected
        if (ubbBold1<ubbBold2) {
            // [b] comes before [/b]
            tempmsg = tempmsg.replace("[b]", "<b>");
            tempmsg = tempmsg.replace("[/b]", "</b>&nbsp;");
        }
    }
}
// Configure italic
ubbItalic1 = tempmsg.indexOf("[i]", [0]);
ubbItalic2 = tempmsg.indexOf("[/i]", [0]);
if ((ubbItalic1 != undefined) && (ubbItalic2 != undefined)) {
    if ((ubbItalic1 != -1) && (ubbItalic2 != -1)) {
        // [i] and [/i] detected
        if (ubbItalic1<ubbItalic2) {
            // [i] comes before [/i]
            tempmsg = tempmsg.replace("[i]", "<i>");
            tempmsg = tempmsg.replace("[/i]", "</i>&nbsp;");
        }
    }
}
// Configure underline
ubbUnderline1 = tempmsg.indexOf("[u]", [0]);
ubbUnderline2 = tempmsg.indexOf("[/u]", [0]);
if ((ubbUnderline1 != undefined) && (ubbUnderline2 != undefined)) {
    if ((ubbUnderline1 != -1) && (ubbUnderline2 != -1)) {
        // [u] and [/u] detected
        if (ubbUnderline1<ubbUnderline2) {
            // [u] comes before [/u]
            tempmsg = tempmsg.replace("[u]", "<u>");
            tempmsg = tempmsg.replace("[/u]", "</u>&nbsp;");
        }
    }
}
// Configure shout
ubbshout1 = tempmsg.indexOf("[s]", [0]);
ubbshout2 = tempmsg.indexOf("[/s]", [0]);
if ((ubbshout1 != undefined) && (ubbshout2 != undefined)) {
    if ((ubbshout1 != -1) && (ubbshout2 != -1)) {
        // [shout] and [/shout] detected
        if (ubbshout1<ubbshout2) {
            // [shout] comes before [/shout]
            thisshout = tempmsg.substring(ubbshout1+3, ubbshout2);
            tempmsg = tempmsg.remove(thisshout);
            thisshout = thisshout.toUpperCase();
            tempmsg = tempmsg.replace("[s]", "<font color=\&quot;#FF0000\&quot;><b>"+thisshout);
            tempmsg = tempmsg.replace("[/s]", "</b></font>&nbsp;");
        }
    }
}
// Configure url
ubbUrl1 = tempmsg.indexOf("[url]", [0]);
ubbUrl2 = tempmsg.indexOf("[/url]", [0]);
if ((ubbUrl1 != undefined) && (ubbUrl2 != undefined)) {
    if ((ubbUrl1 != -1) && (ubbUrl2 != -1)) {
        // [url] and [/url] detected
        if (ubbUrl1<ubbUrl2) {
            // [url] comes before [/url]
            thisurl = tempmsg.substring(ubbUrl1+5, ubbUrl2);
            if (thisurl.substr(0, [7]) != "http://") {
                thisurl = "http://"+thisurl;
            }
            tempmsg = tempmsg.replace("[url]", "<font color=\&quot;#FFCC00\&quot;><a href=\&quot;"+thisurl+"\&quot; target=\&quot;_blank\&quot;><b>");
            tempmsg = tempmsg.replace("[/url]", "</b></a></font>&nbsp;");
        }
    }
}
if (swearing == 1) {
    tempmsg = tempmsg+"<i> - please do not swear</i>";
}
finaltempmsg = tempmsg;

// FUNCTIONS USED IN THE ABOVE CODE

/*
Functions for replacing strings etc - not all used ;-)
*/
String.prototype.constructor.stringUtilsDefined = true;
String.prototype.constructor.stringUtilsVersion = 1.5;
/**
*    This methods trims all of the white space from the left side of a String.
*/
String.prototype.ltrim = function() {
    var size = this.length;
    for (var i = 0; i<size; i++) {
        if (this.charCodeAt(i)>32) {
            return this.substring(i);
        }
    }
    return "";
};
/**
*    This methods trims all of the white space from the right side of a String.
*/
String.prototype.rtrim = function() {
    var size = this.length;
    for (var i = size; i>0; i--) {
        if (this.charCodeAt(i)>32) {
            return this.substring(0, i+1);
        }
    }
    return "";
};
/**
*    This methods trims all of the white space from both sides of a String.
*/
String.prototype.trim = function() {
    return this.rtrim().ltrim();
};
/**
*    This methods returns true if the String begins with the string passed into
*    the method. Otherwise, it returns false.
*/
String.prototype.beginsWith = function(s) {
    return (s == this.substring(0, s.length));
};
/**
*    This methods returns true if the String ends with the string passed into
*    the method. Otherwise, it returns false.
*/
String.prototype.endsWith = function(s) {
    return (s == this.substring(this.length-s.length));
};
String.prototype.remove = function(remove) {
    return this.replace(remove, "");
};
String.prototype.replace = function(replace, replaceWith) {
    sb = new String();
    found = false;
    for (var i = 0; i<this.length; i++) {
        if (this.charAt(i) == replace.charAt(0)) {
            found = true;
            for (var j = 0; j<replace.length; j++) {
                if (!(this.charAt(i+j) == replace.charAt(j))) {
                    found = false;
                    break;
                }
            }
            if (found) {
                sb += replaceWith;
                i = i+(replace.length);
            }
        }
        sb += this.charAt(i);
    }
    return sb;
};