用正则匹配年月日数据

/^(\d{4})-(\d{2})-(\d{2})/.exec("2023-08-17 16:44:17")
["2023-08-17", "2023", "08", "17"]
/(\d{4})-(\d{2})-(\d{2})/.exec("2023-08-17 16:44:17")
["2023-08-17", "2023", "08", "17"]
/\d{4}-\d{2}-\d{2}/.exec("2023-08-17 16:44:17")返回是数组

原文地址:https://www.cnblogs.com/afterwawa/p/5688715.html