Split a Camel-Cased word into its components

I needed to split a camel-cased word into it’s component parts, and found the following extension method to help out. It works pretty well.

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" );
}

20110409-060908.jpg

This entry was posted in .NET, C# Snippets, Extension Methods, Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>