capitalize

Capitalize first letter of each word in a selection using vim

南笙酒味 提交于 2019-11-28 15:57:09
In vim, I know we can use ~ to capitalize a single char (as mentioned in this question ), but is there a way to capitalize the first letter of each word in a selection using vim? For example, if I would like to change from hello world from stackoverflow to Hello World From Stackoverflow How should I do it in vim? You can use the following substitution: s/\<./\u&/g \< matches the start of a word . matches the first character of a word \u tells Vim to uppercase the following character in the substitution string (&) & means substitute whatever was matched on the LHS ernix :help case says: To turn

Regular expression for checking if capital letters are found consecutively in a string?

人盡茶涼 提交于 2019-11-27 17:23:06
I want to know the regexp for the following case: The string should contain only alphabetic letters. It must start with a capital letter followed by small letter. Then it can be small letters or capital letters. ^[A-Z][a-z][A-Za-z]*$ But the string must also not contain any consecutive capital letters. How do I add that logic to the regexp? That is, HttpHandler is correct, but HTTPHandler is wrong. edit: 2015-10-26: thanks for the upvotes - but take a look at tchrist's answer. (one below) especially if you develop for the web or something more "international". Oren Trutners answer isn't quite

How do I capitalize first letter of first name and last name in C#?

痞子三分冷 提交于 2019-11-27 06:09:13
Is there an easy way to capitalize the first letter of a string and lower the rest of it? Is there a built in method or do I need to make my own? ageektrapped 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

Regex capitalize first letter every word, also after a special character like a dash

帅比萌擦擦* 提交于 2019-11-27 04:36:41
I use this #(\s|^)([a-z0-9-_]+)#i for capitalize every first letter every word, i want it also to capitalize the letter if it's after a special mark like a dash(-) Now it shows: This Is A Test For-stackoverflow And i want this: This Is A Test For-Stackoverflow Any suggestions/samples for me? I'am not a pro, so try to keep it simple for me to understand. A simple solution is to use word boundaries : #\b[a-z0-9-_]+#i Alternatively, you can match for just a few characters: #([\s\-_]|^)([a-z0-9-_]+)#i +1 for word boundaries, and here is a comparable Javascript solution. This accounts for

Capitalize First Letter Of Each Word In A String - JavaScript

痞子三分冷 提交于 2019-11-26 22:08:04
What is wrong with this function? I am lost thanks for help. function titleCase(str) { var splitStr = str.toLowerCase().split(' '); for (var i = 0; i < splitStr.length; i++) { if (splitStr.length[i] < splitStr.length) { splitStr[i].charAt(0).toUpperCase(); } str = splitStr.join(' '); } return str; } titleCase("I'm a little tea pot"); somethinghere You are not assigning your changes to the array again, so all your efforts are in vain. Try this: function titleCase(str) { var splitStr = str.toLowerCase().split(' '); for (var i = 0; i < splitStr.length; i++) { // You do not need to check if i is

Capitalize first letter. MySQL

☆樱花仙子☆ 提交于 2019-11-26 21:40:42
Does any one know the equivalent to this TSQL in MySQL parlance? I am trying to capitalize the first letter of each entry. UPDATE tb_Company SET CompanyIndustry = UPPER(LEFT(CompanyIndustry, 1)) + SUBSTRING(CompanyIndustry, 2, LEN(CompanyIndustry)) 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

How to capitalize the first letter of a String in Java?

馋奶兔 提交于 2019-11-26 14:06:34
I am using Java to get a String input from the user. I am trying to make the first letter of this input capitalized. I tried this: String name; BufferedReader br = new InputStreamReader(System.in); String s1 = name.charAt(0).toUppercase()); System.out.println(s1 + name.substring(1)); which led to these compiler errors: Type mismatch: cannot convert from InputStreamReader to BufferedReader Cannot invoke toUppercase() on the primitive type char Rekin String str = "java"; String cap = str.substring(0, 1).toUpperCase() + str.substring(1); // cap = "Java" With your example: public static void main

How do I capitalize first letter of first name and last name in C#?

送分小仙女□ 提交于 2019-11-26 11:52:15
问题 Is there an easy way to capitalize the first letter of a string and lower the rest of it? Is there a built in method or do I need to make my own? 回答1: 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

python capitalize first letter only

孤街浪徒 提交于 2019-11-26 09:20:24
问题 I am aware .capitalize() capitalizes the first letter of a string but what if the first character is a integer? this 1bob 5sandy to this 1Bob 5Sandy 回答1: If the first character is an integer, it will not capitalize the first letter. >>> '2s'.capitalize() '2s' If you want the functionality, strip off the digits, you can use '2'.isdigit() to check for each character. >>> s = '123sa' >>> for i, c in enumerate(s): ... if not c.isdigit(): ... break ... >>> s[:i] + s[i:].capitalize() '123Sa' 回答2:

Capitalize first letter. MySQL

笑着哭i 提交于 2019-11-26 07:59:58
问题 Does any one know the equivalent to this TSQL in MySQL parlance? I am trying to capitalize the first letter of each entry. UPDATE tb_Company SET CompanyIndustry = UPPER(LEFT(CompanyIndustry, 1)) + SUBSTRING(CompanyIndustry, 2, LEN(CompanyIndustry)) 回答1: 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