Reputation: 2024
In visual studio's find and replace, I'm trying to replace (P|Q)1 with the p or the Q followed by a 2. So P1 with P2 and Q1 with Q2. however, $12
seems to look for capture group 12 so it just shows up as literally $12
. Any character I put between the 1 and the 2, including backslash, shows up. Can this be done?
Upvotes: 2
Views: 168
Reputation: 627126
You can safely use
([PQ])1
and replace with ${1}2
(since {}
around the group ID makes the ID unambiguous) even in VS2012.
If you are unsure of what is going on with numbered backreferences, you can always use named captures:
(?<val>[PQ])1
and replace with ${val}2
.
Upvotes: 2