Using Regular Expressions In The Replace Dialog - Visual Studio

Visual Studio 2010

Wrapping part of the Find What expression in curly braces allows you to refer to it in the Replace With expression via \number.

Example #1

For example, using
Find What = Cells\("{[A-Za-z]*}"\)
Replace With= Cells(\1.Name)

will replaceCells("uxDefaultCheckboxColumn")
withCells(uxDefaultCheckboxColumn.Name)

Example #2

To transform SQL from this...

a.City + ', ' + a.State + ' ' + a.ZipCode as CityStateZip

to this...

CityStateZip = a.City + ', ' + a.State + ' ' + a.ZipCode

use these settings in the Find and Replace dialog

Find What = ,{.+} as {.+}
Replace With= ,\2 = \1

Visual Studio 2012

Wrapping part of the Find What expression in parenthesis allows you to refer to it in the Replace With expression via $number.

Example

For example, using
Find What = Cells\("([A-Za-z]*)"\)
Replace With= Cells($1.Name)

will replaceCells("uxDefaultCheckboxColumn")
withCells(uxDefaultCheckboxColumn.Name)

Example #2

To find all HTML file references that start with "http:", search for (src|href)[ \t]*=[ \t]*["'][ \t]*http:

Note: It's strongly recommended that, after performing the above search, that you search all server code (C# or VB) for "http:".

Changes since VS 2010

In Visual Studio 2012, the following changes were made