Reputation: 175
for example replace with varible group replacement
def x=2
"var1var2".replaceAll(/var(.*?)var(.+)/ , '$${x}' )
for obtain 2
Upvotes: 0
Views: 619
Reputation: 171084
I think you want:
"var1var2".replaceAll(/var(.*?)var(.+)/ , "\$${x}")
That will return the second group, so 2
A better example (with only one 2
in it would be)
"var3var4".replaceAll(/var(.*?)var(.+)/ , "\$${x}")
That will return 4
Upvotes: 1