/*
* vim 表情替换处理
* author tangw
*/
//表情的基本数据
var FaceData =function(){
var data =
[
["微笑",":)","wx","0.gif"],
["撇嘴",":~","pz","1.gif"],
["色",":*","se","2.gif"],
["发呆",":|","fd","3.gif"],
["得意","8-)","dy","4.gif"],
["流泪",":<","ll","5.gif"],
["害羞",":$","hx","6.gif"],
["闭嘴",":X","bz","7.gif"],
["睡",":Z","shui","8.gif"],
["大哭",":'(","dk","9.gif"],
["尴尬",":-|","gg","10.gif"],
["发怒",":@","fn","11.gif"],
["调皮",":P","tp","12.gif"],
["呲牙",":D","cy","13.gif"],
["惊讶",":0","jy","14.gif"],
["难过",":(","ng","15.gif"],
["酷",":+","kuk","16.gif"],
["冷汗","--b","lengh","17.gif"],
["抓狂",":Q","zk","18.gif"],
["吐",":T","tu","19.gif"],
["偷笑",";P","tx","20.gif"],
["可爱",";-D","ka","21.gif"],
["白眼",";d","baiy","22.gif"],
["傲慢",";o","am","23.gif"],
["饥饿",":g","jie","24.gif"],
["困","|-)","kun","25.gif"],
["惊恐",":!","jk","26.gif"],
["流汗",":L","lh","27.gif"],
["憨笑",":>","hanx","28.gif"],
["大兵",":",";db","29.gif"],
["奋斗",";f","fendou","30.gif"],
["咒骂",":-S","zhm","31.gif"],
["疑问","?","yiw","32.gif"],
["嘘",";x","xu","33.gif"],
["晕",";x","yun","34.gif"],
["折磨",":-S","zhm","35.gif"],
["衰",";!","shuai","36.gif"],
["骷髅","!!!","kl","37.gif"],
["敲","xx","qiao","38.gif"],
["再见","bye","zj","39.gif"],
["擦汗","wipe","ch","40.gif"],
["抠鼻","dig","kb","41.gif"],
["鼓掌","handclap","gz","42.gif"],
["糗大了","&-(","qd","43.gif"],
["坏笑","B-)","huaix","44.gif"],
["左哼哼","<@","zhh","45.gif"],
["右哼哼","@<","yhh","46.gif"],
["哈欠",":-0","hq","47.gif"],
["鄙视",">-|","bs","48.gif"],
["委屈","P-(","wq","49.gif"],
["快哭了",":'|","kk","50.gif"],
["阴险","X-)","yx","51.gif"],
["亲亲",":*","qq","52.gif"],
["吓","@x","xia","53.gif"],
["可怜","8*","kel","54.gif"],
["菜刀","pd","cd","55.gif"],
["西瓜","<w>","xig","56.gif"],
["啤酒",":beer","pj","57.gif"],
["篮球","basketb","lq","58.gif"],
["乒乓","oo","pp","59.gif"],
["咖啡","coffee","kf","60.gif"],
["饭","eat","fan","61.gif"],
["猪头","pig","zt","62.gif"],
["玫瑰","rose","mg","63.gif"],
["凋谢","fade","dx","64.gif"],
["示爱","showlove","sa","65.gif"],
["爱心","heart","xin","66.gif"],
["心碎","break","xs","67.gif"],
["蛋糕","cake","dg","68.gif"],
["闪电","li","shd","69.gif"],
["炸 弹","bome","zhd","70.gif"],
["刀","kn","dao","71.gif"],
["足球","footb","zq","72.gif"],
["瓢虫","ladybug","pch","73.gif"],
["便便","shit","bb","74.gif"],
["月亮","moom","yl","75.gif"],
["太阳","sun","ty","76.gif"],
["礼物","gift","lw","77.gif"],
["拥抱","hug","yb","78.gif"],
["强","strong","qiang","79.gif"],
["弱","weak","ruo","80.gif"],
["握手","share","ws","81.gif"],
["胜利","v","shl","82.gif"],
["抱拳","@)","bq","83.gif"],
["勾引","jj","gy","84.gif"],
["拳头","@@","qt","85.gif"],
["差劲","bad","cj","86.gif"],
["爱你","loveu","aini","87.gif"],
["NO","no","bu","88.gif"],
["OK","OK","hd","89.gif"]
];
return data;
}
//
function getReplaceFace(code){
for(var i=0;i<FaceData().length;i++){
var arr = FaceData()[i];
if( code == arr[3]){
return "[FACE]"+arr[0]+"[/FACE]";
}
}
}
//通过编码得到表情gif文件
function getFaceGIFByCode(code){
for(var i=0;i<FaceData().length;i++){
var arr = FaceData()[i];
if( arr[0] == code || arr[1] ==code || arr[2] ==code ){
return "<img alt=\"\" src=\"vim/js/kindeditor/plugins/emoticons/"+arr[3]+"\" border=\"0\" />";
}
}
}
//<img alt=\"\" src=\"..\/plugins\/emoticons\/(\d+.gif)\" border=\"0\" \/> 替换成 [face][/face]
function imgReplaceFace(str){
var arr;
var src = str;
var re = /<img alt=\"\" src=\"vim\/js\/kindeditor\/plugins\/emoticons\/(\d+.gif)\" border=\"0\" \/>/g; //创建正则表达式对象。
while( (arr = re.exec(str)) != null ) {
var s = getReplaceFace(arr[1]);
src = src.replace(/<img alt=\"\" src=\"vim\/js\/kindeditor\/plugins\/emoticons\/(\d+.gif)\" border=\"0\" \/>/,s);
}
return src;
}
//[face][/face] 替换成 <img alt=\"\" src=\"..\/plugins\/emoticons\/(\d+.gif)\" border=\"0\" \/>
function faceReplaceImg(str){
var arr;
var src = str;
var re = /\[(FACE|face)\]([^[\/FACE]+)\[\/(FACE|face)\]/g; //创建正则表达式对象。
while( (arr = re.exec(str)) != null ) {
var s = getFaceGIFByCode(arr[2]);
src = src.replace(/\[(FACE|face)\]([^[\/FACE]+)\[\/(FACE|face)\]/,s);
}
return src;
}
分享到:
相关推荐
105个微信qq默认表情图片打包附带对照表和js正则替换示例和php代码默认表情图片打包附带对照表和js正则替换示例和php代码默认表情图片打包附带对照表和js正则替换示例和php代码默认表情图片打包附带对照表和js正则...
总结来说,"微信qq默认表情图片打包附带对照表和js正则替换示例和php代码"这一主题涵盖了图像处理、文本解析、正则表达式应用以及前端和后端的代码实现。在实际开发中,理解这些知识点可以帮助我们更好地集成和处理...
JavaScript正则替换示例可能是用来从用户输入的文本中识别和提取emoji字符的代码。在JavaScript中,正则表达式(Regular Expression)是一种强大的文本处理工具,可以用来匹配、查找、替换等操作。例如,一个简单的...
您可能感兴趣的文章:C#将隐私信息(银行账户,身份证号码)中间部分特殊字符替换成*PHP的substr_replace将指定两位置之间的字符替换为*号PHP中利用substr_replace将指定两位置之间的字符替换为*号js正则
- **正则表达式**:使用正则表达式可以高效地匹配并移除或替换特殊字符和表情符号。例如,`[^\w\s]` 可以匹配非字母数字和空格的字符。 - **字符串函数**:Java中的`String.replaceAll()`方法,可以结合正则表达式...
本文将深入探讨如何使用JavaScript有效地处理来自iOS和Android设备的emoji表情符号。 首先,我们需要了解的是,iOS和Android设备使用的emoji编码并不完全相同。iOS主要使用Unicode标准中的图形字符,而Android则...
正则表达式是一种强大的文本处理工具,它能够利用特定的字符串模式来搜索、匹配、替换文本中的内容。在处理网页和网络数据时,特别是涉及到图片地址和img标签的情况下,正则表达式变得尤为重要。图片地址和img标签是...
- 正则表达式处理:在进行字符串匹配或替换时,使用`preg_match`和`preg_replace`等函数,确保正则表达式模式设置为多字节(例如`/u`修饰符)。 2. **MySQL存储emoji**: - 数据库字符集设置:确保MySQL数据库、...
- 使用正则表达式:`preg_match_all()`函数配合正则表达式可以匹配Unicode表情,例如`'/[\x{1F600}-\x{1F64F}]/u'`用于匹配基本表情符号。 2. **处理图片表情**: - 数据库存储:将表情以图片URL的形式存储在...
总的来说,"jquery新浪微博表情插件"是一个结合了jQuery库、JavaScript语言特性、正则表达式、DOM操作、数据结构、事件处理、动态内容加载等多种技术的前端开发实例。它不仅提升了用户的交互体验,也为开发者提供了...
这涉及到正则表达式的使用,来匹配并替换表情编码。 - 表情图片通常存储在`css`或`smiley`、`smile_old`这样的文件夹下,这些文件夹可能包含了不同风格的的表情图片。例如,`smile_old`可能包含了老版本的表情,而...
正则表达式是JavaScript中非常强大的文本处理工具,它允许对字符串中的内容进行复杂的搜索、匹配和替换操作。本文将通过实例代码的形式,详细讲解在JavaScript中如何巧妙地使用正则表达式进行操作。 首先,正则...
在处理表情替换时,CSS可以用来定义每个表情的样式,包括大小、颜色、动画等。在这个项目中,`weixinEmoji-master`文件名表明这是一个主分支或主版本,通常包含项目的完整代码库。 在“weixinEmoji”项目中,开发者...
这涉及到字符串处理和正则表达式的使用,我们需要编写函数来匹配并替换textarea中的表情代码。 `微信表情`是指微信应用中特有的表情集合,它们通常以特定的格式存储,并在聊天界面中显示。虽然我们不能直接使用微信...