capitalize

Calling methods within methods to Titleize in Ruby

安稳与你 提交于 2019-12-08 09:05:12
问题 I am trying to create a titleizing method for a programming assignment, it capitalizes certain words and ignores others. It always capitalizes the first word. To this end, I made a method that finds the first word of a string, and tried to call it within the titleize method. I'm getting an error that says "warning: string literal in condition". I've tried changing the phrasing of the if loop around, but it's not fixing my error. Can anyone explain to my why my code is broken? Thanks so much

how to CaPiTaLiZe every other character in php?

亡梦爱人 提交于 2019-12-06 03:43:14
I want to CaPiTaLiZe $string in php, don't ask why :D I made some research and found good answers here, they really helped me. But, in my case I want to start capitalizing every odd character (1,2,3...) in EVERY word. For example, with my custom function i'm getting this result "TeSt eXaMpLe" and want to getting this "TeSt ExAmPlE". See that in second example word "example" starts with capital "E"? So, can anyone help me? : ) Here's a one liner that should work. preg_replace('/(\w)(.)?/e', "strtoupper('$1').strtolower('$2')", 'test example'); http://codepad.org/9LC3SzjC Well I would just make

Capitalise first letter in String [duplicate]

ⅰ亾dé卋堺 提交于 2019-12-05 08:44:41
问题 This question already has answers here : How to capitalize the first letter of a String in Java? (51 answers) Closed 6 years ago . I'm having trouble converting the first letter to Capital in a String: rackingSystem.toLowerCase(); // has capitals in every word, so first convert all to lower case StringBuilder rackingSystemSb = new StringBuilder(); rackingSystemSb.append(rackingSystem); rackingSystemSb.setCharAt(0, Character.toUpperCase(rackingSystemSb.charAt(0))); rackingSystem =

Capitalize first letter of TextView in an Android layout xml file

不羁的心 提交于 2019-12-04 12:51:47
I have a TextView in a layout xml file like this: <TextView android:id="@+id/viewId" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/string_id" /> My string is specified like this: <string name="string_id">text</string> Is it possible to make it display "Text" instead of "text" without java code ? (and without changing the string itself either) No. But you can create a simple CustomView extending TextView that overrides setText and capitalizes the first letter as Ahmad said like this and use it in your XML layouts. import android.content.Context;

How do I echo text in capital letters?

倾然丶 夕夏残阳落幕 提交于 2019-12-04 04:33:53
问题 I want to know how to capitalize in PHP 回答1: echo strtoupper('hello'); strtoupper will capitalize the whole string. If you're only interested in capitalizing the first letter, you can use ucfirst: echo ucfirst('hello!'); //Hello! If you want to capitalize the first letter of each word in a string, use ucwords: echo ucwords('hello world!'); //Hello World! 回答2: The strtoupper() function is what you're looking for. 来源: https://stackoverflow.com/questions/1054631/how-do-i-echo-text-in-capital

Ruby on Rails uncapitalize first letter

不想你离开。 提交于 2019-12-03 10:32:54
问题 I'm running Rails 2.3.2. How do I convert "Cool" to "cool" ? I know "Cool".downcase works, but is there a Ruby/Rails method that does the opposite of capitalize , i.e., uncapitalize or decapitalize ? 回答1: There is no inverse of capitalize , but you can feel free to roll your own: class String def uncapitalize self[0, 1].downcase + self[1..-1] end end 回答2: There is also: "coolat_cat".camelize(:lower) # => "coolCat" 回答3: You could also do this with a simple sub : "Cool".sub(/^[A-Z]/) {|f| f

text-transform: capitalize; Also affects Placeholder

江枫思渺然 提交于 2019-12-03 09:36:01
I have the following simple input. <input type="text" placeholder="What is your username?" /> When I use text-transform: capitalize; to capitalize the first letter of each word, the placeholder also gets capitalized: What Is Your Username? How can I keep the placeholder intact? You could style the placeholder-- ::-webkit-input-placeholder { text-transform: initial; } :-moz-placeholder { text-transform: initial; } ::-moz-placeholder { text-transform: initial; } :-ms-input-placeholder { text-transform: initial; } 来源: https://stackoverflow.com/questions/22415038/text-transform-capitalize-also

Automatically capitalize first letter of first word in a new sentence in LaTeX

寵の児 提交于 2019-12-03 06:16:21
I know one of LaTeX's bragging points is that it doesn't have this Microsoftish behavior. Nevertheless, it's sometimes useful. LaTeX already adds an extra space after you type a (non-backslashed) period, so it should be possible to make it automatically capitalize the following letter as well. Is there an obvious way to write a macro that does this, or is there a LaTeX package that does it already? The following code solves the problem. \let\period. \catcode`\.\active \def\uppercasesingleletter#1{\uppercase{#1}} \def.{\period\afterassignment\periodx\let\next= } \def \periodx{\ifcat\space\next

Ruby on Rails uncapitalize first letter

家住魔仙堡 提交于 2019-12-03 01:03:53
I'm running Rails 2.3.2. How do I convert "Cool" to "cool" ? I know "Cool".downcase works, but is there a Ruby/Rails method that does the opposite of capitalize , i.e., uncapitalize or decapitalize ? There is no inverse of capitalize , but you can feel free to roll your own: class String def uncapitalize self[0, 1].downcase + self[1..-1] end end tfischbach There is also: "coolat_cat".camelize(:lower) # => "coolCat" You could also do this with a simple sub : "Cool".sub(/^[A-Z]/) {|f| f.downcase } str = "Directly to the south" str[0] = str[0].downcase puts str #=> "directly to the south" There

Capitalize input text in Javascript

本小妞迷上赌 提交于 2019-12-02 21:15:40
问题 In a form, I have two buttons to transform text to uppercase and lowercase. I am using this function to transform input text to upper case: document.xyz.textinput.value=document.xyz.textinput.value.toUpperCase() Now, I want to add a new button to capitalize each word. Is it possible to achieve this with the following code? document.xyz.textinput.value=document.xyz.textinput.value.capitalize() Thanks 回答1: Try This: document.xyz.textinput.value = document.xyz.textinput.charAt(0).toUpperCase() +