c# 使用正则实现万分位分隔符

public static string Str4Split(String str)
{
String oper = "";

if (!String.IsNullOrEmpty(str) && str.StartsWith("-"))
{
str = str.Remove(0, 1);
oper = "-";
}

str=System.Text.RegularExpressions.Regex.Replace(str, @"(\d{4})", ",$1", System.Text.RegularExpressions.RegexOptions.RightToLeft).Trim(',');

return oper + str;


}

posted @ 2017-03-25 15:31  唔愛吃蘋果  阅读(577)  评论(1编辑  收藏  举报