Showing posts with label visual studio find replace tagged expressions. Show all posts
Showing posts with label visual studio find replace tagged expressions. Show all posts

Wednesday, December 12, 2007

Visual Studio Find & Replace with Tagged Expressions

This is an example on how to use tagged expressions in Visual Studio Find & Replace dialog.

Say you need to replace all of the ocurrences of

MyMethod<MyType>("Identity");

with something like

(MyType)Fields["Identity"];

Then, you have to find

MyMethod\<{:w+}\>\(\"{:w+}\"\);

and replace it by

(\1)Fields["\2"];

Simple.

Notice two things here:
  1. the backslashes before every reg exp metacharacter in the Find statement
  2. the absence of them in the Replace statement