In Visual Studio, when I search within a selection, I want to replace the first instance (or second, third, etc.) of a match per line using regular expressions. How would I do this?
Search and replace
foo1 = foo1;
foo2 = foo2;
...
foo20 = foo20;
into the following.
foo1 = bar1;
foo2 = bar2;
...
foo20 = bar20;
In Visual Studio 2010 and earlier, use regular expressions with back references
Visual Studio’s regular expressions are completely different from what I’ve learned. Took me some time to figure out the correct answer.
Search for
Replace with
Back references are done by
taggingwith curly braces{foo}.:d+is the same for\d+Read more about VS RegEx here