Parses a camel cased or pascal cased string and returns a new string with spaces between the words in the string. - CSharp System

CSharp examples for System:String Case

Description

Parses a camel cased or pascal cased string and returns a new string with spaces between the words in the string.

Demo Code


using System.Collections.Specialized;
using System.Text.RegularExpressions;
using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w w w.  jav a 2s . c o  m*/

public class Main{
        //The functions that follow I have found this url: http://weblogs.asp.net/jgalloway/archive/2005/09/27/426087.aspx
        /// <summary>
        /// Parses a camel cased or pascal cased string and returns a new
        /// string with spaces between the words in the string.
        /// </summary>
        /// <example>
        /// The string "PascalCasing" will return an array with two
        /// elements, "Pascal" and "Casing".
        /// </example>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string SplitUpperCaseToString(this string source)
        {
            return string.Join(" ", SplitUpperCase(source));
        }
}

Related Tutorials