Created
May 14, 2019 06:26
-
-
Save wullemsb/a917d869d050eef7834036faaa7a8541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class StringExtensions | |
{ | |
public static string ToSnakeCase(this string input) | |
{ | |
var startUnderscores = Regex.Match(input, @"^_+"); | |
return startUnderscores + Regex.Replace(input, @"([a-z0-9])([A-Z])", "$1_$2").ToLower(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment