问题
I would like to understand the patterns they are using for their smileys.
回答1:
If emoticons are only replaced if surrounded by whitespace or (presumably) at start/end of a line/string, then you can use a series of regexes.
Using this list (taken from http://www.skype-forum.com/ftopic13197.html),...
you can construct these like this:
(?<=^|\s)<<smiley regex>>(?=\s|$)
will match <<smiley regex>> only if it's on its own.
Examples for <<smiley regex>>:
:-?\) :-?\( :-?D 8\)
;\( \(sweat\) :\| :\*
:\$ :\^\) \|-\) \|\(
;\) \]:\) \(talk\) \(yawn\)
\(doh\) :@ \(wasntme\) \(party\)
etc. - you'll need to escape a lot of special-meaning characters for use in a regex. Your language might have a re.escape() function for this.
来源:https://stackoverflow.com/questions/5077842/skype-smileys-regexp-patterns-where-how-to-get