General answer: write down the part you want to keep in parentheses, and include it in the substitution string as $1 .
See the regexp lookup guide for more details.
Here: just turn it on . and ( to the substitution string.
For the exercise, write a regular expression that will turn any line of the circuit --ABC--DEF-- into --DEF--ABC-- for arbitrary alphabetic values ABC and DEF . So, --XY--IJK-- should turn into --IJK--XY-- . Here you really need to use capture groups and backlinks.
source share