Home > Net >  How can i tell a string starts with an emoji and get the first emoji in the string, without using re
How can i tell a string starts with an emoji and get the first emoji in the string, without using re

Time:01-18

I've seen some answers here providing monstrous regular expressions to get emojis from a string. But is there a more algorithmic approach? I mean, operation systems and browsers parse emoji-containing strings somehow, i doubt its done with regexes?

CodePudding user response:

I've knocked up the below extension method / demo; hopefully that's some help.

Caveat: I don't know much about this area; so please don't treat this as gospel; and ensure you test thoroughly before relying on it.

In fact - the reason the regex answer comes up so often is probably because that's currently the best answer, given the complexity.

using System;
using System.Globalization;

public class Demo
{
    void Main()
    {
        var emojiString = "           
  • Related