Mega Code Archive

 
Categories / C# Book / 11 Regular Expression Basics
 

0650 Splitting a camel-cased word

This requires a positive lookahead to include the uppercase separators: using System; using System.Text.RegularExpressions; class Program { static void Main(string[] args) { string r = @"(?=[A-Z])"; foreach (string s in Regex.Split ("oneTwoThree", r)) Console.Write (s + " "); // one Two Three } } The output: one Two Three