c# - Regex: Remove everything except emoticons. how? -


this question has answer here:

if have string such "i love country :) :d. myself :p -_- .", how remove except emoticons - resulting string should without text ? input string or text can type.

i using regex

regex.replace(str, "[a-za-z]", ""); 

but remove "p""d" in ":d :p" smiley. regex then?

thanks in advance.

there lot of emoticons so wil. end long , on complicated regular expression but. in case think care of 2 'corrupted' emoticons after replace. if case, should work:

[abce-oq-za-oq-z]|(?<!:)d|(?<!:)[pp] 

this regular expresssion match on abc, range e o , ragne of q z lowercase letters matches o , q z. key part in regular expression matches d, p , p if matched char not preceded colon. feature called lookaround (or in exact use case lookbehind).


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -