uppercase

if/else statements accepting strings in both capital and lower-case letters in python

我的梦境 提交于 2019-12-01 15:57:27
问题 Is there a quick way for an "if" statement to accept a string regardless of whether it's lower-case, upper-case or both in python? I'm attempting to write a piece of code where the number "3" can be entered as well as the word "three"or "Three" or any other mixture of capital and lower-case and it will still be accepted by the "if" statement in the code. I know that I can use "or" to get it to accept "3" as well as any other string however don't know how to get it to accept the string in more

How to code a C++ program which counts the number of uppercase letters, lowercase letters and integers in an inputted string?

风格不统一 提交于 2019-12-01 14:54:50
I'm looking for a simple and basic way (ideal for beginners to learn the easiest way) to write a program in C++ which gets a string from the user and outputs the number of uppercase letters, lowercase letters and integers (numbers). I'm pretty amateur at using C++ syntax so please help me with an easy-to-understand syntax. Thanks! EDIT: Here is a very simple code that I found in Google and did some changes and corrections: #include <iostream> #include <conio.h> using namespace std; int main() { char array1[50]; int i = 0, lowercase = 0, uppercase = 0, numbers = 0, total; cout << "Enter a

Automatically capitalize all input in WPF

て烟熏妆下的殇ゞ 提交于 2019-12-01 13:44:28
问题 Is there a way to automatically capitalize all input thoughtout a WPF app? 回答1: You can case all input into TextBox controls with the following property: CharacterCasing="Upper" To apply to all TextBox controls in the entire application create a style for all TextBox controls: <Style TargetType="{x:Type TextBox}"> <Setter Property="CharacterCasing" Value="Upper"/> </Style> 回答2: I recommend creating a custom Textbox class and override an event to automatically capitalize the text. First, this

In ruby how do you tell if a string input is in uppercase or lowercase?

孤者浪人 提交于 2019-12-01 10:38:31
I am trying to write a program that when a single letter is inputted, if it's in uppercase, leave it in uppercase and return it, and if it's in lowercase, then convert to uppercase. How do I write this to be able to tell if the string is originally in uppercase or lowercase? Just convert the string to upper case and compare it with the original string == string.upcase or for lowercase string == string.downcase Edit: as mentioned in the comments the solution above works with English letters only. If you need an international solution instead use def upcase?(string) !string[/[[:lower:]]/] end

Jackson - converting java object to json - Need all key keys to upper case

寵の児 提交于 2019-12-01 07:16:37
Need your help on conversion of java objects to json. current the json result showing all the key in small letter case, i need it to be upper case. ObjectMapper mapper = new ObjectMapper(); Writer strWriter = new StringWriter(); mapper.writeValue(strWriter, obj); String jsonString= strWriter.toString(); and the result is [{"flags":"1","name":"Peter","location":"London","startDate":"2012-01-06 00:00"}] but i want results like this (all key key value should be in UPPER CASE): [{"FLAGS":"YU","NAME":"Peter","LOCATION":"London","STARTDATE":"2012-01-06 00:00"}] and also is it possible to get like

Swift 2 : Iterating and upper/lower case some characters

霸气de小男生 提交于 2019-12-01 05:09:50
I want to modify a Swift string by converting some characters to uppercase, some others to lowercase. In Obj-c I had following : - (NSString*) lowercaseDestination:(NSString*) string { NSUInteger length = string.length; unichar buf[length+1]; [string getCharacters:buf]; BOOL up = true; for (int i=0; i< length ; i++) { unichar chr = buf[i]; if( .... ) { buf[i] = toupper(chr); } else { buf[i] = tolower(chr); } } string = [NSString stringWithCharacters:buf length:length]; return string; How would you do that in Swift 2 ? I did no find any Character method to upper or lower the case. Would be an

Turn a User Input String to Upper Case Java

对着背影说爱祢 提交于 2019-12-01 04:05:07
This may seem like a silly question, but after going through pages of google, i havnt been able to find the answer i want. s1.setName(JOptionPane.showInputDialog("Enter Name: "); For the above piece fo code, how would i format the data the user entered to be all capitals? Any help here would be appreciated. The String class has a toUpperCase() method on it. JOptionPane.showInputDialog(..) returns a String, so you can use: JOptionPane.showInputDialog("Enter name: ").toUpperCase(); See String.toUpperCase() Remember that String is immutable, so this creates a duplicate string 来源: https:/

Java - Convert lower to upper case without using toUppercase()

▼魔方 西西 提交于 2019-12-01 03:48:47
问题 I'm trying to create a short program that would convert all letters that are uppercase to lowercase (from the command line input). The following compiles but does not give me the result I am expecting. What would be the reason for this?? Eg) java toLowerCase BANaNa -> to give an output of banana public class toLowerCase{ public static void main(String[] args){ toLowerCase(args[0]); } public static void toLowerCase(String a){ for (int i = 0; i< a.length(); i++){ char aChar = a.charAt(i); if

Finding all uppercase letters of a string in java

孤者浪人 提交于 2019-12-01 03:34:18
问题 So I'm trying to find all the uppercase letters in a string put in by the user but I keep getting this runtime error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 4 at java.lang.String.charAt(String.java:686) at P43.main(P43.java:13) I feel foolish but I just can't figure this out and oracle even talks about charAt on the page about java.lang.StringIndexOutOfBoundsException Here is my code for finding the uppercase letters and printing them:

Swift 2 : Iterating and upper/lower case some characters

妖精的绣舞 提交于 2019-12-01 02:47:54
问题 I want to modify a Swift string by converting some characters to uppercase, some others to lowercase. In Obj-c I had following : - (NSString*) lowercaseDestination:(NSString*) string { NSUInteger length = string.length; unichar buf[length+1]; [string getCharacters:buf]; BOOL up = true; for (int i=0; i< length ; i++) { unichar chr = buf[i]; if( .... ) { buf[i] = toupper(chr); } else { buf[i] = tolower(chr); } } string = [NSString stringWithCharacters:buf length:length]; return string; How