Visual Studio.NET offers Regular expressions for both search and search & replace. Unfortunately, Microsoft don't follow the traditional syntax for regular expressions - and the feature is almost undocumented. I had to use google groups to find out how to use search-results in the replacement-expression.

Normally you group regular expressions with pharanthesis '(' ')'. Visual Studio accepts this, but it will not retain the match for the replace expression. You have to use '{' '}' in stead. Also, you would normally excpect to use $n (where n is the expression in group n in the search expression.) - but you must use \n in stead. I don't really understand why Microsoft woun't simply keep with the standards.

Anyway, using regular expressions in search/replace is an extreemly powerful feature - especially when you can run the command against an entire project or solution.

Here is what I used to replace all
    #include "*war*.h"
with
   #include <*war*.h>

in a solution with about 300 files.

    Search expression: {include\ "}{.*war.*}{\"}

Replace expression: include <\2>


As you see, I group the search for header-file includes in three, where the actual name of the file is in group 2. Then I use \2 in the replace expression to get the filename. The whole thing did it's job in just a few seconds. Very impressive! This could be done under Linux as well - but not quite that simple - and not restricted within the files for one C++ project - spread around in quite a number of directories. I just Wish Microsoft had used the normal syntax for regular expressions - then I would have saved the 30 minutes I spend figuring out how to make it work ;)