Skip to content

Instantly share code, notes, and snippets.

@lisardggY
Created October 16, 2017 07:40
Show Gist options
  • Save lisardggY/715cfab81370ed9eeb161302f5a1417b to your computer and use it in GitHub Desktop.
Save lisardggY/715cfab81370ed9eeb161302f5a1417b to your computer and use it in GitHub Desktop.
IEnumerable<string> GetAlternateSpellings(string baseName)
{
if (string.IsNullOrWhiteSpace(baseName))
yield break;
yield return baseName;
if (baseName.Contains("_"))
{
yield return Regex.Replace(baseName, @"(_)([a-z])", m => m.Groups.Cast<Group>().Last().Value.ToUpper());
}
else if (char.IsLower(baseName[0]))
{
yield return Regex.Replace(baseName, @"([A-Z])", m => "_" + m.Value.ToLower());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment