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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -