prashantas
prashantas

Reputation: 455

substring extracting in groovy from another string

I have a string:

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

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

Upvotes: 0

Views: 128

Answers (4)

dmahapatro
dmahapatro

Reputation: 50285

pRoiGroup[++pRoiGroup.indexOf(/#/)..-2] //No list involved

Upvotes: 0

tim_yates
tim_yates

Reputation: 171194

Or:

def result = pRoiGroup.find( /#([a-f0-9]*)]/ ) { it[ 1 ] }

Upvotes: 0

BIdesi
BIdesi

Reputation: 371

def result= pRoiGroup.split("#")[1][0..-2]

Upvotes: 1

acsadam0404
acsadam0404

Reputation: 2841

String result = pRoiGroup - "[com.testing.Location#" - "]"

Upvotes: 1

Related Questions