Basically the idea is to map the emoticons in the string to actual words. say for :) you replace it with happy. A more clear example would be. Original: Today is a sunny day :). But tomorrow it is going to rain :(. Final: Today is a sunny day happy. But tomorrow it is going to rain sad.
I have trying a solution using a common regex for all emoticons but I am not sure once you detect it is an emoticon, how to go back and replace each one with appropriate word. I need it only for three emoticons :),:( and :D. Thank you.
Why don't you use a plain replace? You have just three fixed patterns:
Use
Regex.Replace
method that takes a custom match evaluator.A more general solution:
For any additional emoticons that need replacing, just add another key-value-pair, like
{":D", "laughing"}
to the dictionary.As an alternative to the foreach-loop, it would also be possible (though not necessarily recommended) to use the
Aggregate
standard query operator:Why regex?