SplitPascalCase
Splits the given string by pascal case.
Source
/*
Requires a reference System.Text.RegularExpressions.
*/
/// <summary>
/// Splits the string by pascal case.
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
public static string SplitPascalCase(this string text)
{
if (string.IsNullOrEmpty(text))
{
return text;
}
return Regex.Replace(text, "([A-Z])", " $1", RegexOptions.Compiled).Trim();
}
Example
var str = "ThisIsAPascalCaseString";
return str.SplitPascalCase();
/*
"This Is A Pascal Case String"
*/