Reputation: 37
May I know how to extract the substring "10111" from string "some infor [1:5] 10111" in groovy? The following code written by me, are there any better way to do this?
parentString = "some infor [1:5] 10111"
String childString = parentString
println childString.substring(16)
Upvotes: 0
Views: 185
Reputation: 28564
def parentString = "some infor [1:5] 10111"
def childString = parentString.replaceAll( /.*\[\d+:\d+]\s*(.*)/ , '$1' )
println childString
about regex: https://regex101.com/r/MWVdGX/1
Upvotes: 1