lowercase

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

Lowercase characters to Uppercase characters in C & writing to file

青春壹個敷衍的年華 提交于 2019-12-02 23:39:19
问题 I am reading content from a file to be read into a char array in C. How could I change all the letters in the file that are lowercase to uppercase letters? 回答1: Here's a possible algorithm: Open a file (let's call it A) - fopen() Open another file to write (let's call it B) - fopen() Read the content of A - getc() or fread(); whatever you feel free Make the content you read uppercase - toupper() Write the result of the 4-step to B - fwrite() or fputc() or fprintf() Close all file handles -

.toLowerCase not working, replacement function?

让人想犯罪 __ 提交于 2019-12-02 21:39:49
The .toLowerCase method is giving me an error when I try to use it on numbers. This is what I have: var ans = 334; var temp = ans.toLowerCase(); alert(temp); And then it gives me this error: 'undefined' is not a function (evaluating 'ans.toLowerCase()') I don't know where I got this wrong. I always thought that numbers can also be parsed, with no change in result (maybe that's where I stuffed up). But if that's not the error, can someone write a custom makeLowerCase function, to make the string lower case, perhaps using regex or something? .toLowerCase function only exists on strings. You can

SQL changing a value to upper or lower case

谁都会走 提交于 2019-12-02 19:54:56
How do you make a field in a sql select statement all upper or lower case? Example: select firstname from Person How do I make firstname always return upper case and likewise always return lower case? SELECT UPPER(firstname) FROM Person SELECT LOWER(firstname) FROM Person Stephen Wrighton LCASE or UCASE respectively. Example: SELECT UCASE(MyColumn) AS Upper, LCASE(MyColumn) AS Lower FROM MyTable SQL SERVER 2005: print upper('hello'); print lower('HELLO'); You can use LOWER function and UPPER function . Like SELECT LOWER('THIS IS TEST STRING') Result: this is test string And SELECT UPPER('this

Converting Odd and Even-indexed characters in a string to uppercase/lowercase in Javascript?

南笙酒味 提交于 2019-12-02 18:15:36
问题 I need to make a function that reads a string input and converts the odd indexed characters in the string to upperCase and the even ones to lowerCase. function alternativeCase(string){ for(var i = 0; i < string.length; i++){ if (i % 2 != 0) { string[i].toUpperCase(); } else { string[i].toLowerCase(); } } return string; } How to fix my code? 回答1: Try this: function alternativeCase(string){ var output = ""; for(var i = 0; i < string.length; i++){ if (i % 2 != 0) { output += string[i]

Increment a string from numbers 0-9 to lowercase a-z to uppercase A-Z in C#

最后都变了- 提交于 2019-12-02 17:21:38
问题 I want to be able to have a string 6 characters long starting with '000000'. Then I want to increment it by one '000001' when I hit 9 I want to go to '00000a' when I get to z I want to go to '00000A'. When 'Z' is reached I want to reset the first to 0 and start with the next position '000010' So on and so forth. '000011','000012'...'0000a0','0000a1'...'0000A0','0000A1' How would I do this in C#? Thank you in advance. Mike 回答1: This uses the IntToString supporting arbitrary bases from the

Users to register only lower case letters

三世轮回 提交于 2019-12-02 14:35:59
问题 I have this register page , and i would like to have the script register only lower case letters : pretty I do not want it to register :Pretty , PRETTy , PRETTY ... Here is the code , what do i need to add , or do i change something in the DB ? Thanks so much for the help ! public function addField($field_name){ if (!array_key_exists($field_name, $this->fields)) { if ($field_name=='username') { $field = new field_join_username(); parent::registerField($field); } if ($field_name=='email') {

Lowercase characters to Uppercase characters in C & writing to file

。_饼干妹妹 提交于 2019-12-02 13:40:10
I am reading content from a file to be read into a char array in C. How could I change all the letters in the file that are lowercase to uppercase letters? Here's a possible algorithm: Open a file (let's call it A) - fopen() Open another file to write (let's call it B) - fopen() Read the content of A - getc() or fread(); whatever you feel free Make the content you read uppercase - toupper() Write the result of the 4-step to B - fwrite() or fputc() or fprintf() Close all file handles - fclose() The following is the code written in C: #include <stdio.h> #include <ctype.h> #define INPUT_FILE

Getting string index out of range? python 3

北战南征 提交于 2019-12-02 11:24:16
问题 My program is supposed to take an input in form of a string and split into to strings, one with all the lower case letters, underscores and dots. The other one with all the upper cases, the pipes and the spaces. I am not supposed to use (for function) def split_rec (letters): uppers = "" lowers = "" if letters[0].isupper() or letters[0] == "|" or letters[0].isspace(): uppers += letters[0] + split_rec (letters[1:]) elif letters[0].islower() or letters[0] == "_" or letters[0] == ".": lowers +=

Converting Odd and Even-indexed characters in a string to uppercase/lowercase in Javascript?

ⅰ亾dé卋堺 提交于 2019-12-02 11:12:37
I need to make a function that reads a string input and converts the odd indexed characters in the string to upperCase and the even ones to lowerCase. function alternativeCase(string){ for(var i = 0; i < string.length; i++){ if (i % 2 != 0) { string[i].toUpperCase(); } else { string[i].toLowerCase(); } } return string; } How to fix my code? Try this: function alternativeCase(string){ var output = ""; for(var i = 0; i < string.length; i++){ if (i % 2 != 0) { output += string[i].toUpperCase(); } else { output += string[i].toLowerCase(); } } return output; } function alternativeCase(string){