← All source files

V4 / 2d54b29f17a8

KokoroIdentifiers.cs

Lilith/Core/Kokoro/KokoroIdentifiers.cs

Changed in this version
CS
using System.Text.RegularExpressions;

namespace Lilith.Core.Kokoro;

internal static class KokoroIdentifiers
{
    private static readonly string[] Digits = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
    // Approval/bin hashes are identifiers, not large integers. Keep display/history untouched.
    internal static string Expand(string text) => Regex.Replace(text, @"(?<![A-Za-z0-9])[A-Fa-f0-9]{24,64}(?![A-Za-z0-9])",
        match => string.Join(" ", match.Value.Select(c => c is >= '0' and <= '9' ? Digits[c - '0'] : c.ToString())));
}