Say I have the following string
String Context = "old1 old2 old3 old4 old5 old6"
I wish to do a pattern: (old2).*(old4)
so word 2 would be in $1 and word4 would be in $2.
Is there any functions or methods that i can replace the two words strings at the same time? Using only the group variable ($1 and $2) ?
So I could specify that $1 will become new2 and $2 will become new4.
I don't want to have to find the string old2 and old4 and replace it to new2 and new4
old2andold4and replace it withnew2andnew4.