ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


Turn any string formed with camel case into a human cased string.


public static IEnumerable<string> SplitCamelCase(this string source)
    const string pattern = @"[A-Z][a-z]*|[a-z]+|\d+";
    var matches = Regex.Matches(source, pattern);
    foreach (Match match in matches)
        yield return match.Value;

public static string CamelCaseToHumanCase(this string source)
    var words = source.SplitCamelCase();
    string humanCased = string.Join(" ", words);
    return humanCased;


string camelCaseString = "CamelCaseString";
string humanCased = stringForSplit.CamelCaseToHumanCase();
// Result: "Camel Case String"

Author: Piero Alvarez Fuentes

Submitted on: 3 aug 2018

Language: C#

Type: System.String

Views: 4744