zl程序教程

您现在的位置是:首页 >  后端

当前栏目

C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字

c#正则表达式 字符串 数字 或者 去掉 使用
2023-09-11 14:15:05 时间
        /// 去掉字符串中的数字  

        public static string RemoveNumber(string key)  
        {  
            return Regex.Replace(key, @"\d""");  
        }  


//去掉字符串中的非数字
public static string RemoveNotNumber(string key)  
{  
    return Regex.Replace(key, @"[^\d]*""");  
}