如何在文本中删除小写? [英] How to remove lowercase on a textbox?

查看:120
本文介绍了如何在文本中删除小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图删除在文本框 ..

例如,短

txtDesc.text = "Blue Cross Blue Shield";

string Code = //This must be BCBS.. 



这是可能?请帮帮我。 !谢谢

Is it possible? Please help me. Thanks!

推荐答案

那么你可以使用正则表达式来去除,这不是资本AZ一切:

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);
    }
}

请注意,这将删除任何非ASCII字符。另一种正则表达式是:

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.

这篇关于如何在文本中删除小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆