mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 23:11:54 +00:00
25 lines
739 B
C#
25 lines
739 B
C#
using System.Text.RegularExpressions;
|
|
using System.Text;
|
|
|
|
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;
|
|
}
|
|
|
|
public static string ToBase64String(string input)
|
|
{
|
|
return Convert.ToBase64String(Encoding.UTF8.GetBytes(input));
|
|
}
|
|
} |