Proper case match : Regular Expression : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Regular Expression »

 

Proper case match








    
 

using System;
using System.Text.RegularExpressions;


public class RXProperCaseApp {
    static void Main(string[] args) {
        string s = "the qUEEn wAs in HER parLOr";
        s = s.ToLower();
        string e = @"\w+|\W+";
        string sProper = "";

        foreach (Match m in Regex.Matches(s, e)) {
            sProper += char.ToUpper(m.Value[0])
                + m.Value.Substring(1, m.Length - 1);
        }
        Console.WriteLine("ProperCase:\t{0}", sProper);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Regular Expression