Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Using Regular Expressions In The Replace Dialog - Visual Studio

RSS
Modified on Thu, Dec 19, 2013, 10:14 AM by Administrator Categorized as Regular Expressions, Visual Studio and Developer Tools

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
  • In the Find what field, capture groups are now wrapped in parenthesis instead of curly braces.
  • In the Replace with field, capture groups are now referenced via a dollar sign instead of a backslash.

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2018, Patrick Jasinski.