To find a regular expression, replace a regular emoticon with an emoticon (<img> emoticons)

Source: Internet
Author: User
To find a regular expression, replace a regular emoticon with an emoticon (emoticon)

[Happy] to be replaced by (the Chinese name of the picture is not regulated?) )

In fact, it is better to use JS to better.


Reply to discussion (solution)

$str = ' [happy] emoji image ';
echo preg_replace ('/\[(. *) \]/', "", $str);

These days, everything is in the right ...
It is certainly not advisable to use Chinese names for filenames.

function Replacestr ($STR) {
$str =substr ($str, Strpos ($str, ' [') +1,strlen ($STR)-2);
Return "";
}

Excuse me, how efficient is it to replace the entire page?

$str = ' [happy] emoji image ';
echo preg_replace ('/\[(. *) \]/', "", $str);

should also be acceptable.

I found a JQ plugin on the Internet, in the client to replace, for [happy] this kind of English emoji can be replaced, but once the [happy] Chinese emoji do not, um, I also feel that the Chinese do not have a bad file name.

JQuery Plugins:on/off emtions var __emotion__cache = false;jquery.fn.emotions = function () {    var aemotion = new Ar Ray ();        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));                                       });}

These days, everything is in the right ...
It is certainly not advisable to use Chinese names for filenames.

function Replacestr ($STR) {
$str =substr ($str, Strpos ($str, ' [') +1,strlen ($STR)-2);
Return "";
}

Chinese file name is very bad all kinds of incompatible egg ache ...

Take a look at the wood with the wrong hints.

alert (str);
See if it's replaced.


It is estimated that the name of the image is the Chinese name reason. Switch to English.

The JQ plugin is a 0.png, 1.png, 2.png replacement [face]
But it's strange to change face to Chinese.

Take a look at the wood with the wrong hints.

alert (str);
See if it's replaced.


It is estimated that the name of the image is the Chinese name reason. Switch to English.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.