Reputation: 99
I would like to know if it was possible in "IntelliJ" to replace (CTRL + SHIFT + R) with the capture of the regex that allows to find the occurrences.
My regex: \b(\w+)\s?:\s?+\1\b\s?[,}]
I can't find myself any information about it.
My objective is to replace:
model: model,
by
model,
Thank you, Jimmy.
Upvotes: 2
Views: 507
Reputation: 163237
In your pattern you are already referring to the first capturing group using a backreference and you could also use that in the replacement.
To keep the second part, one option is to use a second capturing group and in the replacement refer to those capturing groups using $1$2
\b(\w+)\s?:\s?+\1\b\s?([,}])
^^^^^^
Upvotes: 2