日期:2014-05-20  浏览次数:20758 次

简单的正则表达?
201107131222475391201107131225438372201107180938036337

正则怎样表达每18位加一个逗号?
201107131222475391,201107131225438372,201107180938036337 变成这样

------解决方案--------------------
用,\d{18},匹配出来三条记录,然后再加上,就行了
------解决方案--------------------
"^\d{18}(\,\d{18})*$"
------解决方案--------------------
C# code

//EASY
void Main()
{
    string str="201107131222475391201107131225438372201107180938036337";
    str=Regex.Replace(str,"(?<=\\G.{18})(?!$)",",");
    Console.WriteLine(str);
    //201107131222475391,201107131225438372,201107180938036337
}