c#之正则表达式

127 阅读1分钟

^的使用:^可以定位开头位置

static void Main(string[] args)
        {
            string s = "i am a boy";
            string str=Regex.Replace(s, "^", "here");
            Console.WriteLine(str);
            Console.ReadKey();
        }

的使用:$可以定位结尾位置

 string res = Regex.Replace(s, "$", " you know that");
            Console.WriteLine(res);
            Console.ReadKey();