thecoop
thecoop

Reputation: 46098

How do I convert strings in code to uppercase in Visual Studio?

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?

Upvotes: 4

Views: 2717

Answers (3)

Helen
Helen

Reputation: 97560

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.

Upvotes: 4

JaredPar
JaredPar

Reputation: 754565

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

Upvotes: 2

Joshua
Joshua

Reputation: 1963

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.

Upvotes: 0

Related Questions