Javascript reguläre Ausdrücke ersetzen Text durch Emoticons
Ich muss Text wie @ ersetz;)
oder:p
von Emoticon, aber ich kann keine Regex erstellen, um dies zu erkennen. Jetzt kann ich nur wie @ erkenn: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;
});
}
Was ist der gute Regex dafür?