我正在编写一段代码,该代码使用正则表达式在聊天中查找/替换表情符号。但是,我想使用相同的值数组并将它们作为参考输出。
正则表达式适用于我的搜索,但是当我尝试在输出正则表达式搜索字符串以寻求帮助之前对其进行替换时,我仍然会得到一个斜杠。
:\)
:\(
var emotes = [];
emotes[0] = new Array(':\\\)', 'happy.png');
emotes[1] = new Array(':\\\(', 'sad.png');
function listEmotes(){
var emotestext = '';
for(var i = 0; i < emotes.length; i++){
//Tried this and it doesn't seem to work
//var emote = emotes[i][0];
//emote.replace('\\', '');
emotestext += '<ul>' + emote + ' <img src="emotes/' + emotes[i][1] + '"></ul>';
}
return emotestext;
}