编程技术 · 2020 年 01 月 09 日 0

C#使用正则表达式去除字符串中的汉字

string str =  “中1234″;

str = Regex.Replace(str, @”[\u4e00-\u9fa5]”, “”); //去除汉字

str = Regex.Replace(str, @”[^\u4e00-\u9fa5]”, “”); //只留汉字