• C#回车替换为其他字符


    using System.Text.RegularExpressions;//添加上这个

    private string displace(string myStr, string displaceA, string displaceB)  //定义替换函数,返回的类型为string,   myStr为需修改的字符串,

                                                                                                         //displaceA需替换掉的字符

                                                                                                         //displaceB需替换成的字符

            {
                string[] strArrayA = Regex.Split(myStr, displaceA);  //Regex需使用using System.Text.RegularExpressions;以displaceA为分割成数组

                for (int i = 0; i < strArrayA.Length - 1; i++)
                {
                    strArrayA[i] += displaceB;//数组成员循环添加“需替换的字符”

                }
                string returnStr = "";
                foreach (string var in strArrayA)
                {
                    returnStr += var;//将数组循环添加成字符串
                }
                return returnStr;
            }

     RegEx是Visual Studio .NET中的正则表达式类

  • 相关阅读:
    寻找大富翁
    C++ STL sort()函数用法
    众数
    平方因子
    Hdu 1089 A+B for Input-Output Practice (I)
    Hdu 1090 A+B for Input-Output Practice (II)
    Hdu 1083 Courses
    Hdu 1069 Monkey and Banana
    Hdu 1062 Text Reverse
    Hdu 1068 Girls and Boys
  • 原文地址:https://www.cnblogs.com/tianzhiyun/p/2291755.html
Copyright © 2020-2023  润新知