Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert text to Pascal case?

I have a variable name, say "WARD_VS_VITAL_SIGNS", and I want to convert it to Pascal case format: "WardVsVitalSigns"

WARD_VS_VITAL_SIGNS -> WardVsVitalSigns 

How can I make this conversion?

like image 590
wlz Avatar asked Sep 05 '13 03:09

wlz


1 Answers

You do not need a regular expression for that.

var yourString = "WARD_VS_VITAL_SIGNS".ToLower().Replace("_", " "); TextInfo info = CultureInfo.CurrentCulture.TextInfo; yourString = info.ToTitleCase(yourString).Replace(" ", string.Empty); Console.WriteLine(yourString); 
like image 81
Nilesh Avatar answered Oct 01 '22 05:10

Nilesh