capitalize

php capitalize second letter in sentence min 10 characters long

为君一笑 提交于 2019-12-24 13:55:01
问题 Hello I have a project where I need to cApitalize only the second letter in a sentence. I now that PHP has strtoupper() and string strtoupper ( string $string ) ucfirst() returns first letter So here is my best attempt <?php $str = "capitalize"; $str = ucfirst(strtolower($str)); // makes all the letters lower case ?> This is where I get confused if 0 = the first letter and 1= 2nd then could I just make an array(") or count_chars() then $val 回答1: Its a old question, just came across this so

Rails: Capitalize characters after certain string

删除回忆录丶 提交于 2019-12-24 00:54:53
问题 Using: Rails 3.0.3. I have a string that could be seen as this one: <p>hello, how are you? oh, that's nice! i am glad you are fine. i am too.<br />i am glad to have met you.</p> I want each character following any of <p> <br /> ! ? . to be capitalized. Basically make the string above look good. Is there a standard functionality for that? What should I do? ps. Tried to bold the characters in question, but it didn't work... 回答1: Going off Niklaos answer, I've improved it slightly to take into

using capitalize on a collection_select

浪子不回头ぞ 提交于 2019-12-23 07:58:25
问题 If this has been answered before I cannot find it. I have the following: = f.collection_select :sex_id, @sexes, :id, :name and this in the controller: @sexes = Sex.all the sexes are all stored in lowercase, like this: id|name 1|steer 2|heifer 3|holstein I need them to output with Capital First letters: Steer Heifer Holstein I tried: = f.collection_select :sex_id, @sexes, :id, :name.capitalize = f.collection_select :sex_id, @sexes, 'id', 'name'.capitalize but they do not work, and I didn't

Capitalize first letter of each word in a selection using vim

混江龙づ霸主 提交于 2019-12-17 21:42:04
问题 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? 回答1: 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

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

南笙酒味 提交于 2019-12-17 15:13:14
问题 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. 回答1: Edit: 2015-10-26: thanks for the upvotes - but take a look at tchrist's answer, especially

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

坚强是说给别人听的谎言 提交于 2019-12-17 02:20:50
问题 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 回答1: String str = "java"; String cap = str

How to capitalize a word in a C++ string?

送分小仙女□ 提交于 2019-12-13 16:44:40
问题 I have a std::string and wish for the first letter to be capitalized and the rest lower case. One way I could do this is: const std::string example("eXamPLe"); std::string capitalized = boost::to_lower_copy(example); capitalized[0] = toupper(capitalized[0]); Which would yield capitalized as: "Example" But perhaps there is a more straight forward way to do this? 回答1: If the string is indeed just a single word, std::string capitalized = boost::locale::to_title (example) should do it. Otherwise,

Letter → next letter and capitalize vowels

孤街醉人 提交于 2019-12-13 08:49:43
问题 This code still doesn't seem to be working. It has no errors anymore, but it only returns blank brackets like this {} . It is supposed to turn each letter in str into the next letter and capitalize each vowel. Any ideas? function LetterChanges(str) { str = str.split("");//split() string into array for(var i=0;i<str.length;i++){//for loop that checks each letter if(str[i].match(/[a-y]/i)){ str[i]=String.fromCharCode(str[i].charCodeAt(0)+1); }else if(str[i].match("z")){ str[i] = "a"; } if(str[i

How to capitalize every third letter ot a string in C#?

我们两清 提交于 2019-12-13 07:34:59
问题 does anybody know how to capitalize every third letter of a string in C# ? I loop through the whole string with a for loop, but i can't think of the sequence right now. Thanks in advance 回答1: I suspect you just want something like this: // String is immutable; copy to a char[] so we can modify that in-place char[] chars = input.ToCharArray(); for (int i = 0; i < chars.Length; i += 3) { chars[i] = char.ToUpper(chars[i]); } // Now construct a new String from the modified character array string

Is there a JS equivalent to CSS text-transform: capitalize?

Deadly 提交于 2019-12-12 13:07:50
问题 I've got a hidden <section /> that is comprised of divs that contain content to be stuffed into a jQuery UI dialog. On document.ready I want to loop through those divs, take the id of each respective div, replace dashes with spaces, capitalize each word, and store that in a title variable. Then, I'm going use that in an object literal that gets put into my dialogs[] array. Sounds simple, right? Stripped down version of the HTML: <section id="dialog-content" class="hidden"> <div id="some