c# 标点问题
Session["ESI_EMPNO"] = Session["ESI_EMPNO"] + l_dtDaTable2.Rows[i]["ESI_EMPNO"].ToString();
得到的结果是“9009903090629063”
我想得到“‘9009’,‘9030’,‘9062’,‘9063’”
怎么改?
[解决办法]
%4==0
+","
TrimEnd(',')
[解决办法]
string strNum="90099030906290631";
string res ="";
int i = 0;
while (i+4 < strNum.Length)
{
res += strNum.Substring(i, 4) + ",";
i = i + 4;
}
[解决办法]
string text = @"9009903090629063";
List<string> list = Regex.Split(text,@"(?<=\G\w{4})(?!$)").ToList();
/*
* [0]"9009"string
[1]"9030"string
[2]"9062"string
[3]"9063"string
*/
string text = @"9009903090629063";
string s=string.Join( ",",Regex.Split(text,@"(?<=\G\w{4})(?!$)").Select(a=>string.Format("'{0}'",a)));
//"'9009','9030','9062','9063'"