62,046
社区成员
发帖
与我相关
我的任务
分享
richTextBox2.Text = Regex.Replace("1,2,3,4", @"\d+", "'$0'");
string str="1,2,3,4";
string newstr = "";
string[] strArr = str.Split(new string[1] { "," }, StringSplitOptions.None);
for (int i = 0; i < strArr.Length; i = i + 1)
{
if (newstr == "")
{
newstr = "'" + strArr[i].ToString() + "'";
}
else
{
newstr =newstr+","+ "'" + strArr[i].ToString() + "'";
}
}
Console.Write(Regex.Replace("1,2,3,4", @"(\d)", "'$1'"));
结果:'1','2','3','4'
string a = "1,2,3,4";
a.Replace(",", "','");
a = "'" + a + "'";