using System.Collections.Generic;
private static Dictionary<string, string> emojis = new Dictionary<string, string>
{":panda_face:", "<img src=\"/images/emoji/unicode/1f43c.png\" />"}
private static byte[] emojiParts = new byte[3] { (byte)':', (byte)'_', (byte)':' };
private static byte[] invalidEmojiParts = new byte[3] { (byte)'_', (byte)':', (byte)'_' };
private static List<(int startIndex, int endIndex, string match)> matches = new List<(int, int, string)>();
public static void Main()
Console.WriteLine("Bio Builder");
string test = "blahh blahh blahh :panda_face:";
public static string ParseBio(string bio)
for (var i = 0; i < bio.Length; i++)
if (bio[i] == emojiParts[p])
else if (bio[i] == invalidEmojiParts[p])
if (p == emojiParts.Length)
matches.Add((startIndex, endIndex, match));
Console.WriteLine($"Matches: {matches.Count}");
foreach(var m in matches){
Console.WriteLine($"{m.startIndex} {m.endIndex} \t {m.match}");
if(emojis.ContainsKey(m.Item3)){
var tag = emojis.GetValueOrDefault(m.Item3);
var length = m.Item3.Length;
bio = string.Create(bio.Length - length + tag.Length, (bio, index, length, tag),
state.bio.AsSpan().Slice(0, state.index).CopyTo(span);
state.tag.AsSpan().CopyTo(span.Slice(state.index));
state.bio.AsSpan().Slice(state.index + state.length).CopyTo(span.Slice(state.index + state.tag.Length));
Console.WriteLine($"bio: {bio}");