How to remove the lowercase characters from a textbox retaining only the uppercase? [duplicate]
Possible Duplicate:
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 course(e.g., 'BSCS' for 'Bacheclor of Science in 开发者_如何学运维Computer Science):
Please help me. Thanks!
Use a regular expression:
using System.Text.RegularExpressions;
texbox.Text = Regex.Replace(textbox.Text, "[^A-Z]", "");
Anything you don't want (non-uppercase characters) will be replaced with blank.
Use Char.IsUpper
.
I don't know the actual c# code but I can conceptualize it for you if you're SURE that all acronyms will be properly represented by just the capitals in the given string.
- blow the string up into an array where each array element is a character
- convert each element to it's character representation
- check it against the numeric order of available capital letters
- if it's a capital letter, add it to a variable for use later
Pseudo-code:
$charArray = $string.split("")
foreach ($item in $charArray) {
if ([int]$item > 64 && [int]$item < 91) {
$acronym += [char]$item
}
}
Edit: Here is the character reference chart: http://msdn.microsoft.com/en-us/library/60ecse8t(VS.80).aspx
精彩评论