Lower case all then capitalize – pure CSS [duplicate]
This should do it when you have the single words in different div’s #test3 { text-transform: lowercase; } #test3::first-letter { text-transform: uppercase; } <div id=”test3″>haLLo</div>
This should do it when you have the single words in different div’s #test3 { text-transform: lowercase; } #test3::first-letter { text-transform: uppercase; } <div id=”test3″>haLLo</div>
Only because no one else has mentioned it: >>> ‘bob’.title() ‘Bob’ >>> ‘sandy’.title() ‘Sandy’ >>> ‘1bob’.title() ‘1Bob’ >>> ‘1sandy’.title() ‘1Sandy’ However, this would also give >>> ‘1bob sandy’.title() ‘1Bob Sandy’ >>> ‘1JoeBob’.title() ‘1Joebob’ i.e. it doesn’t just capitalize the first alphabetic character. But then .capitalize() has the same issue, at least in that ‘joe Bob’.capitalize() … Read more
TextInfo.ToTitleCase() capitalizes the first character in each token of a string. If there is no need to maintain Acronym Uppercasing, then you should include ToLower(). string s = “JOHN DOE”; s = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s.ToLower()); // Produces “John Doe” If CurrentCulture is unavailable, use: string s = “JOHN DOE”; s = new System.Globalization.CultureInfo(“en-US”, false).TextInfo.ToTitleCase(s.ToLower()); See the MSDN … Read more
+1 for word boundaries, and here is a comparable Javascript solution. This accounts for possessives, as well: var re = /(\b[a-z](?!\s))/g; var s = “fort collins, croton-on-hudson, harper’s ferry, coeur d’alene, o’fallon”; s = s.replace(re, function(x){return x.toUpperCase();}); console.log(s); // “Fort Collins, Croton-On-Hudson, Harper’s Ferry, Coeur D’Alene, O’Fallon”
Since dart version 2.6, dart supports extensions: extension StringExtension on String { String capitalize() { return “${this[0].toUpperCase()}${this.substring(1).toLowerCase()}”; } } So you can just call your extension like this: import “string_extension.dart”; var someCapitalizedString = “someString”.capitalize();
It’s almost the same, you just have to change to use the CONCAT() function instead of the + operator : UPDATE tb_Company SET CompanyIndustry = CONCAT(UCASE(LEFT(CompanyIndustry, 1)), SUBSTRING(CompanyIndustry, 2)); This would turn hello to Hello, wOrLd to WOrLd, BLABLA to BLABLA, etc. If you want to upper-case the first letter and lower-case the other, you … Read more
Yes, you need to define a directive and define your own parser function: myApp.directive(‘capitalizeFirst’, function($parse) { return { require: ‘ngModel’, link: function(scope, element, attrs, modelCtrl) { var capitalize = function(inputValue) { if (inputValue === undefined) { inputValue=””; } var capitalized = inputValue.charAt(0).toUpperCase() + inputValue.substring(1); if(capitalized !== inputValue) { modelCtrl.$setViewValue(capitalized); modelCtrl.$render(); } return capitalized; } modelCtrl.$parsers.push(capitalize); … Read more
String str = “java”; String cap = str.substring(0, 1).toUpperCase() + str.substring(1); // cap = “Java” With your example: public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // Actually use the Reader String name = br.readLine(); // Don’t mistake String object with a Character object String s1 = name.substring(0, 1).toUpperCase(); … Read more
The .title() method of a string (either ASCII or Unicode is fine) does this: >>> “hello world”.title() ‘Hello World’ >>> u”hello world”.title() u’Hello World’ However, look out for strings with embedded apostrophes, as noted in the docs. The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works … Read more
How do I make the first letter of a string uppercase in JavaScript?