public string GetRePlaceStr(string str, string pattern, string newstr, int index=1)
{
Regex reg = new Regex(pattern);
//查询匹配数量
var t = reg.Matches(str);
return reg.Replace(str, newstr,1,t[index-1].Index);
}
正则表达式替换指定位置的字符串
最新推荐文章于 2024-08-05 07:30:00 发布