C#处理字符串

 public static string FreshString(string str,string cSub)
        {
            if (string.IsNullOrEmpty(str))
                return "";
            if (string.IsNullOrEmpty(cSub))
                throw new Exception("can not unll");
            if (str.Contains(cSub))
                throw new Exception(str+"含有"+ cSub);
            string temp = string.Empty;
            char[] strArry = new char[] { '^', '&', '$', '#', '@', '`' };
            foreach (char tempSub in strArry)
            {
                if (!str.Contains(tempSub))
                {
                    List<string> listPn = new List<string>();
                    listPn = str.Replace(' ', tempSub).Replace("
", tempSub.ToString())
                        .Replace('	', tempSub).Replace('
', tempSub)
.Replace("u00A0",tempSub.ToString())//u00A0是ASCII=160特殊空格nbsp
.Split(tempSub).ToList(). Where(x
=> !string.IsNullOrEmpty(x.Trim())).ToList(); temp = string.Join(cSub, listPn.Select(x => x)); break; } } return temp; }
原文地址:https://www.cnblogs.com/wangjp-1233/p/13373018.html