本文实例讲述了C#基于正则表达式删除字符串中数字或非数字的方法。,具体如下:
/// 去掉字符串中的数字
public static string RemoveNumber(string key)
{
return Regex.Replace(key, @"d", "");
}
//去掉字符串中的非数字
public static string RemoveNotNumber(string key)
{
return Regex.Replace(key, @"[^d]*", "");
}
希望本文所述对大家C#程序设计有所帮助。
注:相关教程知识阅读请移步到c#教程频道。










