func main() {
line := "2022/11/25 19:32 <DIR> 目录"
reg := regexp.MustCompile(`([\d/]+)\s+(\d+:\d+)\s+(<DIR>)\s+(.*)`)
if reg == nil {
panic("命令行解析失败")
}
r := reg.FindAllStringSubmatch(line, -1)
result := r[0]
for _, line := range result {
fmt.Println(line)
}
}
标签:25,正则表达式,result,go,line,reg
From: https://www.cnblogs.com/rush-peng/p/16939484.html