Regex matching emoticons
Match emoji first (to take care of the :pencil: example) and then check for a terminating whitespace or newline: (\:\w+\:|\<[\/\\]?3|[\(\)\\\D|\*\$][\-\^]?[\:\;\=]|[\:\;\=B8][\-\^]?[3DOPp\@\$\*\\\)\(\/\|])(?=\s|[\!\.\?]|$) This regex matches the following (preferring emoji) returning the match in matching group 1: 🙁 🙂 😛 :p :O :3 😐 :/ :\ :$ :* :@ 🙁 🙂 😛 :-p :-O :-3 😐 :-/ :-\ … Read more