uppercase

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

Convert uppercase matches to bold using regex

时间秒杀一切 提交于 2019-12-02 13:01:15
问题 i need to find all uppercase words in a string and set it bold $_POST['descricao'] = "UPPERCASE test WORD" $_POST['descricao'] = preg_replace("\b[A-Z]{2,}\b", "<b>\\1</b>", $_POST['descricao']); it should return: <b>UPPERCASE</b> test <b>WORD</b> 回答1: You need to capture the group and enclose the pattern: preg_replace("/\b([A-Z]{2,})\b/", "<b>\\1</b>", $_POST['descricao']); 回答2: Use this: $_POST['descricao'] = "UPPERCASE test WORD" $_POST['descricao'] = preg_replace("/\b([A-Z]{2,})\b/", "<b>

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){

Another alternating-case in-a-string in Python 3.+

a 夏天 提交于 2019-12-02 10:17:31
问题 I'm very new to Python and am trying to understand how to manipulate strings. What I want to do is change a string by removing the spaces and alternating the case from upper to lower, IE "This is harder than I thought it would be" to "ThIsIsHaRdErThAnItHoUgHtItWoUlDbE" I've cobbled together a code to remove the spaces (heavily borrowed from here): string1 = input("Ask user for something.") nospace = "" for a in string1: if a == " ": pass else: nospace=nospace+a ... but just can't get my head

.net micro (µ) greek letter uppercase issue

蓝咒 提交于 2019-12-02 08:04:39
问题 I have the following code: string firstMicro = "aa \u00b5 bb"; string secondMicro = "aa \u03bc bb"; Assert.IsFalse(firstMicro == secondMicro); string upperFirstMicro = firstMicro.ToUpper(); string upperSecondMicro = secondMicro.ToUpper(); Assert.IsFalse(upperFirstMicro == upperSecondMicro); In my case, the first test passes (obviously, both strings are different), but in second case, the test fails because both texts are identical ($AA M BB). I admit that in one of the cases I should have

Trying to convert uppercase char to lowercase in C without using a function

馋奶兔 提交于 2019-12-02 08:03:31
问题 I am trying to convert a char element from an char *argv[] array to lowercase from uppercase without using a function. I want to add 32 to the ascii integer. When I try to pass the variable as an argument, it will show the integer sum, but not the new lowercase character. Instead it shows the following output: letter h, 104 tolower: 136, � Code: int i = 0; for(i = 0; argv[1][i] != '\0'; i++) { char letter = argv[1][i]; printf("letter %c, %i\n", letter, letter); char tolower = argv[1][i]; int

Trying to convert uppercase char to lowercase in C without using a function

人盡茶涼 提交于 2019-12-02 07:27:11
I am trying to convert a char element from an char *argv[] array to lowercase from uppercase without using a function. I want to add 32 to the ascii integer. When I try to pass the variable as an argument, it will show the integer sum, but not the new lowercase character. Instead it shows the following output: letter h, 104 tolower: 136, � Code: int i = 0; for(i = 0; argv[1][i] != '\0'; i++) { char letter = argv[1][i]; printf("letter %c, %i\n", letter, letter); char tolower = argv[1][i]; int lowercase = tolower + 32; printf("tolower: %i, %c\n", lowercase, lowercase); } Why is it printing a "?"