我正在尝试提取其中的任何数据${}。例如,从这个字符串中提取的数据应该是abc.git commit -m '${abc}'这是实际的代码:re := regexp.MustCompile("${*}")match := re.FindStringSubmatch(command)但这不起作用,你知道吗?
3 回答
慕标5832272
TA贡献1966条经验 获得超4个赞
你也可以试试这个
re := regexp.MustCompile("\\$\\{(.*?)\\}")
str := "git commit -m '${abc}'"
res := re.FindAllStringSubmatch(str, 1)
for i := range res {
//like Java: match.group(1)
fmt.Println("Message :", res[i][1])
}
GoPlay:https : //play.golang.org/p/PFH2oDzNIEi
- 3 回答
- 0 关注
- 921 浏览
添加回答
举报
0/150
提交
取消
