使用场景,sql语句的insert into table(c1,c2,c3) values (v1,v2,v3),(v1,v2,v3),(v1,v2,v3),
 为了提高执行效率,在一个insert into中执行时,在循环中拼接语句,最后一个逗号需要替换为分号才能执行。
        public static string ReplaceLastCommaWithSemicolon(string input)
        {
            int lastCommaIndex = input.LastIndexOf(',');
            if (lastCommaIndex >= 0)
            {
                return input.Remove(lastCommaIndex, 1).Insert(lastCommaIndex, ";");
            }
            else
            {
                return input;
            }
        }

 
 用正则表达式的方法
        public static string ReplaceLastComma(string input)
        {
            string pattern = @",(?=\s*$)"; // 匹配最后一个逗号
            string replacement = @";"; // 将最后一个逗号替换为分号
            string result = Regex.Replace(input, pattern, replacement);  // 执行替换操作
            return result;
        }



















