代码示例:
proc := exec.Command(execString, arg01, arg02, arg03, arg04, arg05)
stdout, err := proc.Output()
res := string(stdout)
fmt.Printeln(res)
此代码的标准输出:
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'cuba'
+--- Project ':cuba-client'
+--- Project ':cuba-client-tests'
+--- Project ':cuba-core'
..........
为此示例,我只需要选择项目名称,即beetwen ':
和'
:
cuba-client
cuba-client-tests
cuba-core
...........
我正在尝试:
re := regexp.MustCompile(`':(.*?)'`)
reg := re.FindAllString(res, -1)
fmt.Println(reg)
并输出:
':cuba-client'
':cuba-client-tests'
':cuba-core'
..............
我在做什么错了?