Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created May 14, 2019 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wullemsb/a917d869d050eef7834036faaa7a8541 to your computer and use it in GitHub Desktop.
Save wullemsb/a917d869d050eef7834036faaa7a8541 to your computer and use it in GitHub Desktop.
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