substring extracting in groovy from another string

2019-08-18 04:08发布

I have a string:

pRoiGroup="[com.testing.Location#533bfa78d3f9645043e4eb25]"

I want to get the string "533bfa78d3f9645043e4eb25" from pRoiGrop. how can I do this ?

标签: groovy
4条回答
Rolldiameter
2楼-- · 2019-08-18 04:44
pRoiGroup[++pRoiGroup.indexOf(/#/)..-2] //No list involved
查看更多
冷血范
3楼-- · 2019-08-18 04:51
def result= pRoiGroup.split("#")[1][0..-2]
查看更多
放荡不羁爱自由
4楼-- · 2019-08-18 04:55
String result = pRoiGroup - "[com.testing.Location#" - "]"
查看更多
Melony?
5楼-- · 2019-08-18 05:01

Or:

def result = pRoiGroup.find( /#([a-f0-9]*)]/ ) { it[ 1 ] }
查看更多
登录 后发表回答