Javascript regex reemplaza el texto con emoticones
Necesito reemplazar texto como;)
o:p
por emoticon pero no puedo crear una expresión regular para detectar esto. Ahora solo puedo detectar como:wink:
function replaceEmoticons(text) {
var emots = {
";)": "wink",
":)": "xxx",
":p": "xxx",
};
return text.replace(/:(.*?):/g, function (match) {
return typeof emots[match] != 'undefined' ?
'<img src="http://localhost:8080/'+emots[match]+'.png"/>' :
match;
});
}
¿Cuál es la buena expresión regular para eso?