2023-05-11T07:38:55.419475598Z 2023-05-11T09:24:12.269054592Z 2023-05-11T12:25:35.379291548Z 2023-05-11T12:32:25.823424117Z

可以使用正则表达式匹配时间格式,例如:

\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{9}Z

然后使用 Go 的正则表达式库进行匹配即可。具体代码如下:

package main

import ( "fmt" "regexp" )

func main() { text := 2023-05-11T07:38:55.419475598Z 2023-05-11T09:24:12.269054592Z 2023-05-11T12:25:35.379291548Z 2023-05-11T12:32:25.823424117Z re := regexp.MustCompile(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{9}Z) matches := re.FindAllString(text, -1) for _, match := range matches { fmt.Println(match) }

2023-05-11T073855419475598Z 2004h0;root1b72ca49a95e root1b72ca49a95e2023-05-11T092412269054592Z 2004h0;root1b72ca49a95e root1b72ca49a95e2023-05-11T122535379291548Z 2004h0;root1b72ca49a95e roo

原文地址: https://www.cveoy.top/t/topic/fcwz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录