using System.Text.RegularExpressions;
public static void Main()
var strList = new [] {"aspNetCore","AspNetCore","ASPNetCore","ASPNetCORE","aspnetcore","ASPNETCORE" };
foreach(var str in strList)
Console.WriteLine($"{str} --> {str.ToKebabCase()}");
public static class KebabConverter
public static string ToKebabCase(this string str)
var str1 = Regex.Replace(str, "[A-Z][a-z]+", m => $"-{m.ToString().ToLower()}");
var str2 = Regex.Replace(str1, "[A-Z]+", m => $"-{m.ToString().ToLower()}");
return str2.TrimStart('-');