我有" origin / blahbranch"我希望子串入#34; blahbranch",如何将其子串?我试过
dev newbranch = (branch1 =~ /.*)[0]
但这让我失望了 1. / sign包括我不想要的 2.嵌入参数$ {newbranch}:
时,实际的git指令返回错误消息"unexpected char: '''"
答案 0 :(得分:1)
假设branch1是字符串,您可以使用拆分功能
List<String> list = new ArrayList<String>(Arrays.asList(branch1.split("/")));
list.remove(0);
def newbranch = String.join("/", list.toArray(new String[0]))
println newbranch
非常简单的解决方案,考虑到远程始终保持origin
,您可以在下面
def newbranch = "origin/blahbrachwithslash/blahbranch".replace("origin/","")
println newbranch