Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在groovy中使用grails从另一个字符串提取子字符串_Groovy - Fatal编程技术网

在groovy中使用grails从另一个字符串提取子字符串

在groovy中使用grails从另一个字符串提取子字符串,groovy,Groovy,我在groovy中有一个字符串pRoiGroup=“[com.testing.Location#533bfa78d3f9645043e4eb25]”。我想从pRoiGrop获取字符串“533bfa78d3f9645043e4eb25”。我可以知道实现我的目标的正确方法是什么吗?也许这个问题太基本了,但我没有找到任何合适的解决方案。请帮助我。也许类似这样的问题 def pRoiGroup = "[com.testing.Location#533bfa78d3f9645043e4eb25]" def

我在groovy中有一个字符串
pRoiGroup=“[com.testing.Location#533bfa78d3f9645043e4eb25]”
。我想从
pRoiGrop
获取字符串
“533bfa78d3f9645043e4eb25”
。我可以知道实现我的目标的正确方法是什么吗?也许这个问题太基本了,但我没有找到任何合适的解决方案。请帮助我。

也许类似这样的问题

def pRoiGroup = "[com.testing.Location#533bfa78d3f9645043e4eb25]"
def part = pRoiGroup.tokenize("#")[1].replaceAll("]", "")
println part

朴素

As数组

def pRoiGroup="[com.testing.Location#533bfa78d3f9645043e4eb25]"
def string = pRoiGroup.split('#')
def finalString = string[1].replace("]", "")
// finalString will be 533bfa78d3f9645043e4eb25 
或者作为ArrayList这样做,答案如下:

可能重复的
def pRoiGroup="[com.testing.Location#533bfa78d3f9645043e4eb25]"
def resultList = pRoiGroup.tokenize('#')
def finalString = resultList.get(1).replace("]", "")