CroMagnon CroMagnon - 5 months ago 55
C# Question

String small replacement

I am searching for a simple way to remove underscores from strings and replacing the next character with its upper case letter.

For example:

From: "data" to: "Data"
From: "data_first" to: "DataFirst"
From: "data_first_second" to: "DataFirstSecond"


Who needs more than one line of code?

var output = Regex.Replace(input, "(?:^|_)($|.)", m => m.Groups[1].Value.ToUpper());