I'm trying to format emojis in my html page with a regex replace code in c#, but the code work fine in regex testers but not working in C#.
Pattern
/&(?:\#(?:(?<dec>[0-9]+)|[Xx](?<hex>[0-9A-Fa-f]+))|(?<named>[A-Za-z0-9]+));/
Value
teste 😀😁😂
Result
teste <span class='emoji'>😀</span><span class='emoji'>😁</span><span class='emoji'>😂</span>
You can test in https://rgxdb.com/try
My C# code
public static string FormatTextEmoji(string pText)
{
//Armazena o retorno
string lReturn = pText;
//Seta a expressão
string lExpression = @"/&(?:\#(?:(?<dec>[0-9]+)|[Xx](?<hex>[0-9A-Fa-f]+))|(?<named>[A-Za-z0-9]+));/";
//Ignora o case
Regex lRegex = new Regex(lExpression, RegexOptions.IgnoreCase);
//Seta a notícia com os links
lReturn = lRegex.Replace(lReturn, "<span class=\"emoji\">$1</span>");
//Retorna o valor
return lReturn;
}
I have another Regex Replace that working fine, i tried a lot of modifications but no success.
Anyone can help me ?