using System.Text.RegularExpressions;

namespace Berufsschule_HAM.Helpers;

public static class StringHelpers
{
    public static string Slugify(string input)
    {
        if (string.IsNullOrWhiteSpace(input))
        {
            return string.Empty;
        }
        input = input.ToLowerInvariant();
        input = Regex.Replace(input, @"[^a-z0-9\s-]", "", RegexOptions.None, TimeSpan.FromMilliseconds(100));
        input = Regex.Replace(input, @"[\s-]+", "-", RegexOptions.None, TimeSpan.FromMilliseconds(100));
        input = input.Trim('-');
        return input;
    }
}