欧洲有习惯,每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;
  }

相关文章:

  • 2021-08-30
  • 2021-11-24
  • 2021-07-03
  • 2022-01-19
  • 2022-01-03
  • 2022-12-23
  • 2021-11-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
相关资源
相似解决方案