Search and replace in Visual Studio

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

{foo}{:d+} = \1\2

Replace with

\1\2 = bar\2

Back references are done by tagging with curly braces {foo}. :d+ is the same for \d+

Read more about VS RegEx here


In Visual Studio 2012, capture groups and backreferences are used just like in C#. You can capture them with common parenthesis, and backreference them with $0, $1, etc. Hope it helps!

Note that the syntax $1 is used for find-replace, but \1 is used for backreferences in the search string.