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


Split any string using camel case pattern.


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;


string stringForSplit = "CamelCaseString";
IEnumerable<string> splittedString = stringForSplit.SplitCamelCase();
// Result: collection with the strings "Camel" "Case" "String"

Author: Piero Alvarez Fuentes

Submitted on: 3 aug 2018

Language: C#

Type: System.String

Views: 2847