Find a regular expression, replace the emoticon of a rule with the expression icon (& lt; img & gt; expression), and find a regular expression, replace a regular emoticons with emoticons (emoticons)
[Happy] is replaced by (the naming rules for images in Chinese are not standard ?)
In fact, it is better to use JS for comparison.
Reply to discussion (solution)
$ Str = '[happy] emoticon image ';
Echo preg_replace ('/\ [(. *) \]/', "", $ str );
This year, everything is regular...
It is not wise to use a Chinese name as a file name.
Function replaceStr ($ str ){
$ Str = substr ($ str, strpos ($ str, '[') + 1, strlen ($ str)-2 );
Return "";
}
How is the efficiency of replacing the entire page?
$ Str = '[happy] emoticon image ';
Echo preg_replace ('/\ [(. *) \]/', "", $ str );
It should be acceptable.
I found a JQ plug-in on the Internet and replaced it on the client. for English emojis such as [happy], they can be replaced, but once changed to [happy] Chinese emojis, they won't work. well, I also feel that the file name in Chinese is not good.
// jQuery Plugins: On/Off Emtions var __emotion__cache = false;jQuery.fn.emotions = function() { var aEmotion = new Array(); aEmotion[21] = new Array('[happy]','\\[happy\\]'); __emotion__cache = true; this.each(function() { str = $(this).html(); for(iEM in aEmotion){ reg = new RegExp(aEmotion[iEM][1],"ig"); str = str.replace(reg,''); } $(this).html(str); });};jQuery.fn.unemotions = function(){ __emotion__cache = false; $('.plugin_emotion').each(function(){ $(this).html(decodeURIComponent(this.title)); });}
This year, everything is regular...
It is not wise to use a Chinese name as a file name.
Function replaceStr ($ str ){
$ Str = substr ($ str, strpos ($ str, '[') + 1, strlen ($ str)-2 );
Return "";
}
Chinese file names are not compatible with various types of pain points...
Check whether there is an error message.
Alert (str );
Check whether it is replaced.
It is estimated that the image name is a Chinese name. Change to English
The JQ plug-in Replaces [face] with 0.png00001.png00002.png.
But it's strange to change face to Chinese...
Check whether there is an error message.
Alert (str );
Check whether it is replaced.
It is estimated that the image name is a Chinese name. Change to English