using System.Collections.Generic;
using System.Text.RegularExpressions;
public static class Program
public static string SplitCamelCase( this string str )
return Regex.Replace( Regex.Replace( str, @"(\P{Ll})(\P{Ll}\p{Ll})", "$1 $2" ), @"(\p{Ll})(\P{Ll})", "$1 $2" );
static List<string> StringSplitter(string stringToSplit)
List<string> result = new List<string>();
bool wasPreviousUppercase = false;
StringBuilder current = new StringBuilder();
foreach (char c in stringToSplit)
if (wasPreviousUppercase)
result.Add(current.ToString());
wasPreviousUppercase = true;
if (wasPreviousUppercase)
char carried = current[current.Length-1];
result.Add(current.ToString());
wasPreviousUppercase = false;
current.Append(char.ToUpper(c));
result.Add(current.ToString());
public static void Main()
string name = "myNewUIControl is a screamDream";
string[] words = Regex.Matches(name, "(^[a-z]+|[A-Z]+(?![a-z])|[A-Z][a-z]+)")
string result = string.Join(" ", words);
Console.WriteLine(result);
string pattern = @"(^[\p{Ll}]+|[\p{Lu}\p{N}]+(?![\p{Ll}])|\p{P}?[\p{Lu}][\p{Ll}]+)";
string input = @"myNewUI12_ControlÀplus";
RegexOptions options = RegexOptions.Multiline | RegexOptions.ECMAScript;
foreach (Match m in Regex.Matches(input, pattern, options))
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
string CamelCaseString = "myNewUI12_ControlÀplus is a great wiZard";
Console.WriteLine( "casedWordHTTPWriter".SplitCamelCase() );
Console.WriteLine( "nothing".SplitCamelCase() );
Console.WriteLine( "ABBA".SplitCamelCase() );
Console.WriteLine( "Computer".SplitCamelCase() );
Console.WriteLine( "aComputer".SplitCamelCase() );
Console.WriteLine( "anAppleComputer".SplitCamelCase() );
Console.WriteLine( "anIBM".SplitCamelCase() );
Console.WriteLine( "anIBMComputer".SplitCamelCase() );
Console.WriteLine( "AppleComputer".SplitCamelCase() );
Console.WriteLine( "IBMComputer".SplitCamelCase() );
Console.WriteLine( "One123Two789".SplitCamelCase() );
Console.WriteLine( "HTTPWriter".SplitCamelCase() );
Console.WriteLine( "HTTPWriter2".SplitCamelCase() );
Console.WriteLine( "JRRTolkien and the LORd of the Rings".SplitCamelCase() );