1. 程式人生 > >刪除字串中的中文

刪除字串中的中文

var str = "123牛4逼5了";
            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;