string a ="bkbk9*2.6/7";
1.去除字符串中非数字
a = Regex.Replace(a, @"[^\d]*", "");//需用到引用usingSystem.Text.RegularExpressions;
去除后a="9267";
2.去除字符串中数字
a = Regex.Replace(a, @"[^\d]*", "");//需用到引用usingSystem.Text.RegularExpressions;
去除后a="bkbk*./";
时间: 2024-10-18 09:14:05