111,126
社区成员
发帖
与我相关
我的任务
分享string s = "2012-5-1 2012-10-10";
string result = Regex.Replace(s, @"(\d{4})-(\d{1,2})-(\d{1,2})",
(x) => x.Groups[1].Value.PadLeft(4, '0') + x.Groups[2].Value.PadLeft(2, '0'));
Console.WriteLine(result);string s = "2012-5-1";
string result = s.Split('-')[0].PadLeft(4, '0') + s.Split('-')[1].PadLeft(2, '0');