本文实例讲述了C#基于正则表达式删除字符串中数字或非数字的方法。分享给大家供大家参考,具体如下:
/// 去掉字符串中的数字
public static string RemoveNumber( string key)
{
return Regex.Replace(key, @"\d" , "" );
}
//去掉字符串中的非数字
public static string RemoveNotNumber( string key)
{
return Regex.Replace(key, @"[^\d]*" , "" );
}
希望本文所述对大家C#程序设计有所帮助。
dy("nrwz");
查看更多关于C#基于正则表达式删除字符串中数字或非数字的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did56230