/// /// 去掉字符串中的数字 /// /// /// public static string RemoveNumber(string key) { return Regex.Replace(key, @"/d", ""); } /// /// 去掉字符串中的非数字 /// /// /// public static string RemoveNotNumber(string key) { return Regex.Replace(key, @"[^/d]*", ""); }
效果:输入"High:4"
第一个函数,输出结果是"High:"
第二个函数,输出结果是"4"
(不含双引号)