Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert all first letter to upper case, rest lower for each word

Tags:

c#

regex

asp.net

I have a string of text (about 5-6 words mostly) that I need to convert.

Currently the text looks like:

THIS IS MY TEXT RIGHT NOW 

I want to convert it to:

This Is My Text Right Now 

I can loop through my collection of strings, but I am not sure how to go about performing this text modification.

like image 235
mrblah Avatar asked Dec 21 '09 23:12

mrblah


People also ask

How do you make the first letter capital and rest lowercase in word?

Or use Word's keyboard shortcut, Shift + F3 on Windows or fn + Shift + F3 for Mac, to change selected text between lowercase, UPPERCASE or capitalizing each word.

Which function converts first letter of every word into upper case?

In JavaScript, we have a method called toUpperCase() , which we can call on strings, or words. As we can imply from the name, you call it on a string/word, and it is going to return the same thing but as an uppercase.

What is it called when you capitalize the first letter of every word?

Title case, which capitalizes the first letter of certain key words. Sentence case, in which titles are capitalized like sentences. Initial case, where the first letter of every word is capitalized.


1 Answers

string s = "THIS IS MY TEXT RIGHT NOW";  s = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(s.ToLower()); 
like image 75
jspcal Avatar answered Oct 24 '22 09:10

jspcal