C# regex to convert camelCase to Sentence case

c#, regex

Solution

One of the ways how you can do it.

string input = "itIsTimeToStopNow";
string output = Regex.Replace(input, @"\p{Lu}", m => " " + m.Value.ToLowerInvariant());
output = char.ToUpperInvariant(output[0]) + output.Substring(1);

Problem

In my example `var key = new CultureInfo("en-GB").TextInfo.(item.Key)` produces, 'Camelcase' what regular expression could I add that would produce a space before the second 'c' ? Examples: 'camelCase' > 'Camel case' 'itIsTimeToStopNow' > 'It is time to stop now'

Original source

Related problems