Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove lowercase on a textbox?

I'm trying to remove the lower case letters on a TextBox..

For example, short alpha code representing the insurance (e.g., 'BCBS' for 'Blue Cross Blue Shield'):

txtDesc.text = "Blue Cross Blue Shield";

string Code = //This must be BCBS.. 

Is it possible? Please help me. Thanks!

like image 718
im useless Avatar asked May 23 '11 05:05

im useless


People also ask

How do you convert lowercase to uppercase?

To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.

How do you get rid of lowercase in python?

Create regular expressions to remove uppercase, lowercase, special, numeric, and non-numeric characters from the string as mentioned below: regexToRemoveUpperCaseCharacters = “[A-Z]” regexToRemoveLowerCaseCharacters = “[a-z]” regexToRemoveSpecialCharacters = “[^A-Za-z0-9]”

How do you change input to lowercase in python?

In Python, lower() is a built-in method used for string handling. The lower() method returns the lowercased string from the given string. It converts all uppercase characters to lowercase. If no uppercase characters exist, it returns the original string.

What is upper case example?

Alternatively known as caps and capital, and sometimes abbreviated as UC, uppercase is a typeface of larger characters. For example, typing a, b, and c shows lowercase, and typing A, B, and C shows uppercase. To type in uppercase, you can use either the Caps Lock key or the Shift key on the keyboard.


2 Answers

Well you could use a regular expression to remove everything that wasn't capital A-Z:

using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main( string[] args )
    {
        string input = "Blue Cross Blue Shield 12356";
        Regex regex = new Regex("[^A-Z]");
        string output = regex.Replace(input, "");
        Console.WriteLine(output);
    }
}

Note that this would also remove any non-ASCII characters. An alternative regex would be:

Regex regex = new Regex(@"[^\p{Lu}]");

... I believe that should cover upper-case letters of all cultures.

like image 126
Jon Skeet Avatar answered Oct 05 '22 14:10

Jon Skeet


string Code = new String(txtDesc.text.Where(c => IsUpper(c)).ToArray());
like image 26
Andrew Cooper Avatar answered Oct 05 '22 13:10

Andrew Cooper