C#去除字符串中的中文

mac2022-06-30  27

public static string DeleteChineseWord(string str) { string retValue = str; if (System.Text.RegularExpressions.Regex.IsMatch(str, @”[\u4e00-\u9fa5]”)) { retValue = string.Empty; var strsStrings = str.ToCharArray(); for (int index = 0; index < strsStrings.Length; index++) { if (strsStrings[index] >= 0x4e00 && strsStrings[index] <= 0x9fa5) { continue; } retValue += strsStrings[index]; } } return retValue; }

参考自:https://blog.csdn.net/qq_37191147/article/details/70139110

最新回复(0)