using System.Text.RegularExpressions;
string s = "I am blue cat.";
string res = Regex.Replace(s, "^","开始:"); // 会替换所有符合正则表达式 ^匹配开头
Console.WriteLine(res); // 开始:I am blue cat.
res = Regex.Replace(s, "$","结束:"); //$匹配结尾
Console.WriteLine(res); //I am blue cat.结束
Author:Ivan正则表达式定位元字符:字符说明^匹配开头$匹配结尾静态判断方法:using System.Text.RegularExpressions;string s = "I am blue cat.";string res = Regex.Replace(s, "^","开始:"); // 会替换所有符合正则表达式 ^匹配开头Console.WriteLine(res); // 开始:I am blue cat.re