Beaker has asked for the wisdom of the Perl Monks concerning the following question:
Someone has just started throwing emoji into text in my site, For the most part I don't mind but I want to strip it from article and thread titles.
Either to change them to plain text completely, or use a regex to strip the emoji specifically.
After looking into this and trying out a bunch of regex I found on stack overflow, it seems there's many types of emoji and I couldn't get any of these to work.
$text =~ s/[\x00-\x1F\x80-\xFF]+\s*//g; $text =~ s/\xEE[\x80-\xBF][\x80-\xBF]|\xEF[\x81-\x83][\x80-\xBF]+\s*// +g; $text =~ s/([0-9#][\x{20E3}])|[\x{00ae}\x{00a9}\x{203C}\x{2047}\x{2048 +}\x{2049}\x{3030}\x{303D}\x{2139}\x{2122}\x{3297}\x{3299}][\x{FE00}-\ +x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF}] +[\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A0 +}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF} +]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE0 +0}-\x{FEFF}]?|[\x{1F000}-\x{1F6FF}][\x{FE00}-\x{FEFF}]|[\x{D83E}][\x{ +DD13}-\x{DD14}]?+\s*//g; $text =~ s/([0-9|#][\x{20E3}])|[\x{00ae}\x{00a9}\x{203C}\x{2047}\x{204 +8}\x{2049}\x{3030}\x{303D}\x{2139}\x{2122}\x{3297}\x{3299}][\x{FE00}- +\x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF} +][\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A +0}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF +}]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE +00}-\x{FEFF}]?|[\x{1F000}-\x{1F6FF}][\x{FE00}-\x{FEFF}]?+\s*//g
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex For Removing Emoji
by Corion (Patriarch) on Nov 12, 2016 at 14:12 UTC | |
by Beaker (Beadle) on Nov 12, 2016 at 17:02 UTC | |
Re: Regex For Removing Emoji
by LanX (Saint) on Nov 12, 2016 at 13:46 UTC | |
by Beaker (Beadle) on Nov 12, 2016 at 14:18 UTC | |
by LanX (Saint) on Nov 12, 2016 at 14:59 UTC | |
by Beaker (Beadle) on Nov 12, 2016 at 17:00 UTC | |
by tye (Sage) on Nov 14, 2016 at 20:05 UTC | |
by Beaker (Beadle) on Nov 12, 2016 at 14:17 UTC |
Back to
Seekers of Perl Wisdom