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

Page History: Using Regular Expressions In The Replace Dialog - Visual Studio

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: Tue, Oct 23, 2012, 2:56 PM


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)

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-2024, Patrick Jasinski.