Monday, February 4, 2008

Split camel casing using regex .NET

ever wonder any better apporoch to convert "BeMyLover" to "Be My Lover"? Here the function in C#.


private string SplitCamelCasing(string input)
{
string output =
"";
return output =
System.Text.RegularExpressions.Regex.Replace(
input,
"([A-Z])",
"
$1",
System.Text.RegularExpressions.RegexOptions.Compiled).Trim();
}

No comments: