62,046
社区成员
发帖
与我相关
我的任务
分享
string str = @"01 2 03 04 05 06
01,2,03,04,05,06
05,9,11,15,21,23,28
01,05,10,4,18,20,25
";
string result1 = Regex.Replace(str, @"\b[1-9]\b", "0$0");
Console.WriteLine(result1);
string str = "05,9,11,15,21,23,28,01,05,10,4,18,20,25";
string result = Regex.Replace(str, @"\d+", m => m.Value.Length > 1 ? m.Value : m.Value.PadLeft(2, '0'));
Console.WriteLine(result);