Skip to content

Instantly share code, notes, and snippets.

@DTTerastar
Created January 16, 2013 17:50
Show Gist options
  • Save DTTerastar/4549181 to your computer and use it in GitHub Desktop.
Save DTTerastar/4549181 to your computer and use it in GitHub Desktop.
Turn Pascal cased Enums and Strings into more readable text by adding spaces
static public string ToStringAddSpaces(this Enum value)
{
string a = value.ToString();
return PascalCaseAddSpaces(a);
}
static public string[] PascalCaseToWords(string value)
{
return Regex.Split(value, "(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])");
}
static public string PascalCaseAddSpaces(string value)
{
return string.Join(" ", PascalCaseToWords(value));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment