Does .Net have a nice way to convert something like this:
MyStringThatIsGreat
into this:
my-string-that-is-great
Ultimatly, I plan to call this in a powershell script, so I am hoping for a few commands that I can convert over to powershell (rather than a large bock of code).
(NOTE: if this a duplicate, I am sorry. I did a search and only saw stuff that went TO pascal case not FROM it to dash case.)
Edit: This is what I was able to coble together:
var pascalCase = "MyReally-CoolMFAString";
var dashCase = Regex.Replace(pascalCase, @"(?<!^)(?<!-)((?<=\p{Ll})\p{Lu}|\p{Lu}(?=\p{Ll}))", "-$1").ToLower();
Console.WriteLine(dashCase);
The output is:
my-really-cool-mfa-string
To make it work with powershell this is the command:
[System.Text.RegularExpressions.Regex]::Replace('MyReally-CoolMFAString', '(?<!^)(?<!-)((?<=\p{Ll})\p{Lu}|\p{Lu}(?=\p{Ll}))', '-$1').ToLower()
Note the single quotes. (Using double quotes you have to escape the $ symbol.)