Código PHP:
$('#contenido').html($(this).val()
.replace(/[code]/gi, "<article class='codigo-comment'>")
.replace(/[s*[/]?code]/gi, "</article>")
.replace(/"/,'"')
.replace(/[b]/gi, '<strong>')
.replace(/[s*[/]?b]/gi, '</strong>')
.replace(/rn|n|r/gi, '<br />')
.replace(/[img src=/gi, '<img class="imgtot" src=')
.replace(/[a href=/gi, '<a class="urlperfect" target="_blank" href=')
.replace(/]/gi, '>')
.replace(/[/gi, '<')
.replace(/[s*[/]?a]/gi,'</a>')
.replace(/(:))/gi,'<img src="bbcode/emoticons/feliz.gif" />')
.replace(/:(/gi,'<img src="bbcode/emoticons/triste.gif" />')
.replace(/(:p)/gi,'<img src="bbcode/emoticons/mostrandolengua.gif" />')
.replace(/(:D)/gi,'<img src="bbcode/emoticons/muyfeliz.gif" />')
.replace(/(:O)/gi,'<img src="bbcode/emoticons/asombrado.gif" />')
.replace(/(;))/gi,'<img src="bbcode/emoticons/guino.gif" />')
.replace(/(:v)/gi,'<img src="bbcode/emoticons/pacman.gif" />')
.replace(/-:-(/gi,'<img src="bbcode/emoticons/enojado.gif" />')
.replace(/(:l)/gi,'<img src="bbcode/emoticons/Duhhh.gif" />')
.replace(/:,(/gi,'<img src="bbcode/emoticons/llorando.gif" />')
.replace(/^_^/gi,'<img src="bbcode/emoticons/ojitos.gif" />')
.replace(/(8-))/gi,'<img src="bbcode/emoticons/gafas.gif" />')
.replace(/(8))/gi,'<img src="bbcode/emoticons/lentesdesol.gif" />')
.replace(/:briyi:/gi,'<img src="bbcode/emoticons/corazon.gif" />')
.replace(/(3:-))/gi,'<img src="bbcode/emoticons/diablo.gif" />')
.replace(/(O:-))/gi,'<img src="bbcode/emoticons/angel.gif" />')
.replace(/:abu:/gi,'<img src="bbcode/emoticons/dork.gif" />')
.replace(/:woow:/gi,'<img src="bbcode/emoticons/woot.gif" />')
.replace(/8-D/gi,'<img src="bbcode/emoticons/risueno.gif" />')
.replace(/:-3/gi,'<img src="bbcode/emoticons/risadegato.gif" />')
.replace(/like/gi,'<img src="bbcode/emoticons/megusta.png" />'));
![Confundido](http://static.forosdelweb.com/fdwtheme/images/smilies/confused.png)
![Confundido](http://static.forosdelweb.com/fdwtheme/images/smilies/confused.png)
![Confundido](http://static.forosdelweb.com/fdwtheme/images/smilies/confused.png)
![Confundido](http://static.forosdelweb.com/fdwtheme/images/smilies/confused.png)
![Confundido](http://static.forosdelweb.com/fdwtheme/images/smilies/confused.png)