这篇文章主要介绍了c#基于正则表达式删除字符串中数字或非数字的方法,涉及c#针对数字的简单正则匹配相关操作技巧,需要的朋友可以参考下
本文实例讲述了C#基于正则表达式删除字符串中数字或非数字的方法。分享给大家供大家参考,具体如下:
/// 去掉字符串中的数字
public static string RemoveNumber(string key)
{
return Regex.Replace(key, @"\d", "");
}
//去掉字符串中的非数字
public static string RemoveNotNumber(string key)
{
return Regex.Replace(key, @"[^\d]*", "");
}










