views:

257

answers:

3

I'm trying to convert all character strings that match a particular regex in a file to uppercase, but I can't find the syntax to specify that within the 'Find and replace' window in visual studio. Is it possible to do this using the visual studio regex?

A: 

press alt + 'e' when the find window has focus to enable "regex" searches.

naturally, you can't 'program' a set of replacement options to insert based on what is found. Each replacement set would require one pass.

Joshua
+2  A: 

It's not possible to do this as a generic replacement using Visual Studio regular expressions. It is possible to re-use the captured text as part of a replacement string using the \n escape sequence where n represents the nth group of captured text. However the regex language only supports limited modifications on this text (mostly justification changes). It doesn't allow you to change case.

Here is a link to the Visual Studio regex language

JaredPar
+2  A: 

As JaredPar has expained, this cannot be done using a generic regular expression search/replace. However, I guess you should be able to do this using a macro.

Helen
macro seems to be a good tool for the task: 1) search with Ctr+F for the first entry 2) get to the beginning of file and start recording (Ctrl+Shift+R) 3) do first conversion (F3, Ctrl+Shift+U, Right) 4) stop recording 5) run macro till it hits end of file (hold Ctrl+Shift+P)
DK