This is called BBCode. Search google for BBCode Inserter or something like that. It requires javascript. But to replace the BBCodes ie [ b]hello[/b] in to hello will require the use of regular expressions. Here is a very basic BBCode Parser, it parses bold, italic and underline BBCode.