软件编程
位置:首页>> 软件编程>> C#编程>> C# 删除字符串中的中文(实例分享)

C# 删除字符串中的中文(实例分享)

作者:欣宇  发布时间:2021-12-30 12:55:48 

标签:C#,删除,字符串

话不多说,请看代码


/// <summary>
/// 删除字符串中的中文
/// </summary>
public static string Delete中文(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;
}

来源:http://www.cnblogs.com/zhang625161495/p/6216952.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com