欧洲有习惯,每3位数值加个逗号分隔,我写了个这样的正则……
(\d+?)(\d{3})*(\.\d+|$)
然后C# 程序里这样用
private string FN(string num)
{
string newstr = string.Empty;
Regex r = new Regex(@"(\d+?)(\d{3})*(\.\d+|$)");
Match m = r.Match(num);
newstr+=m.Groups[1].Value;
for(int i =0;i<m.Groups[2].Captures.Count;i++)
{
newstr+=","+m.Groups[2].Captures[i].Value;
}
newstr+=m.Groups[3].Value;
return newstr;
}