有一串json字符串,我需要将其中的时间格式从yyyy-M-d转换为yyyy/M/d,用c#的正则表达式替换的方法怎么写
如下2015-9-24转换为2015/9/24[{"Data":null,"Time":"2015-9-240:00:00"},{"Data":null,"Time":"...
如下2015-9-24转换为2015/9/24
[{"Data":null,"Time":"2015-9-24 0:00:00"},{"Data":null,"Time":"2015-9-24 1:00:00"},{"Data":null,"Time":"2015-9-24 2:00:00"},{"Data":null,"Time":"2015-9-24 3:00:00"},{"Data":null,"Time":"2015-9-24 4:00:00"},{"Data":null,"Time":"2015-9-24 5:00:00"},{"Data":null,"Time":"2015-9-24 6:00:00"},{"Data":null,"Time":"2015-9-24 7:00:00"},{"Data":null,"Time":"2015-9-24 8:00:00"},{"Data":null,"Time":"2015-9-24 9:00:00"},{"Data":null,"Time":"2015-9-24 10:00:00"},{"Data":null,"Time":"2015-9-24 11:00:00"},{"Data":null,"Time":"2015-9-24 12:00:00"},{"Data":null,"Time":"2015-9-24 13:00:00"},{"Data":null,"Time":"2015-9-24 14:00:00"},{"Data":null,"Time":"2015-9-24 15:00:00"},{"Data":null,"Time":"2015-9-24 16:00:00"},{"Data":null,"Time":"2015-9-24 17:00:00"},{"Data":null,"Time":"2015-9-24 18:00:00"},{"Data":null,"Time":"2015-9-24 19:00:00"},{"Data":null,"Time":"2015-9-24 20:00:00"},{"Data":null,"Time":"2015-9-24 21:00:00"},{"Data":null,"Time":"2015-9-24 22:00:00"},{"Data":null,"Time":"2015-9-24 23:00:00"},{"Data":null,"Time":"2015-9-25 0:00:00"}] 展开
[{"Data":null,"Time":"2015-9-24 0:00:00"},{"Data":null,"Time":"2015-9-24 1:00:00"},{"Data":null,"Time":"2015-9-24 2:00:00"},{"Data":null,"Time":"2015-9-24 3:00:00"},{"Data":null,"Time":"2015-9-24 4:00:00"},{"Data":null,"Time":"2015-9-24 5:00:00"},{"Data":null,"Time":"2015-9-24 6:00:00"},{"Data":null,"Time":"2015-9-24 7:00:00"},{"Data":null,"Time":"2015-9-24 8:00:00"},{"Data":null,"Time":"2015-9-24 9:00:00"},{"Data":null,"Time":"2015-9-24 10:00:00"},{"Data":null,"Time":"2015-9-24 11:00:00"},{"Data":null,"Time":"2015-9-24 12:00:00"},{"Data":null,"Time":"2015-9-24 13:00:00"},{"Data":null,"Time":"2015-9-24 14:00:00"},{"Data":null,"Time":"2015-9-24 15:00:00"},{"Data":null,"Time":"2015-9-24 16:00:00"},{"Data":null,"Time":"2015-9-24 17:00:00"},{"Data":null,"Time":"2015-9-24 18:00:00"},{"Data":null,"Time":"2015-9-24 19:00:00"},{"Data":null,"Time":"2015-9-24 20:00:00"},{"Data":null,"Time":"2015-9-24 21:00:00"},{"Data":null,"Time":"2015-9-24 22:00:00"},{"Data":null,"Time":"2015-9-24 23:00:00"},{"Data":null,"Time":"2015-9-25 0:00:00"}] 展开
2个回答
展开全部
String s = "[{\"Data\":null,\"Time\":\"2015-9-24 0:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 1:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 2:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 3:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 4:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 5:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 6:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 7:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 8:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 9:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 10:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 11:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 12:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 13:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 14:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 15:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 16:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 17:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 18:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 19:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 20:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 21:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 22:00:00\"},{\"Data\":null,\"Time\":\"2015-9-24 23:00:00\"},{\"Data\":null,\"Time\":\"2015-9-25 0:00:00\"}]";
Console.WriteLine(s);
String s0 = Regex.Replace(s, "([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", "$1/$2/$3");
Console.WriteLine(s0);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询