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?
3 Answers
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.

- 87,344
- 17
- 243
- 314
-
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. Aug 28 '09 at 22:05
-
[Adding macro support for VS2012/2013/2015](http://stackoverflow.com/a/13353364/1548895) – Vadim Ovchinnikov Dec 26 '16 at 12:41
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

- 733,204
- 149
- 1,241
- 1,454
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.

- 1,913
- 1
- 19
- 31