Global Search and Replace in Visual Studio

I have a solution with several projects, and we need to make serious global replacements.

Is there a way to make a template replacement where some values ​​remain after the replacement?

So, if I want every HttpContext.Current.Session ["anyvalue"] to become HttpContext.Current.Session ["anyvalue"]. Is string value passed to toring () ? I don't want to replace "anyvalue", I just want to add .ToString () where the pattern matches.

Is this possible in Visual Studio?

+5
source share
6 answers

-, ... .

"/" " ":

"" :

HttpContext\.Current\.Session\["{.@}"\]

"" :

HttpContext.Current.Session["\1"].ToString()
+18

... .

, : (HttpContext.Current.Session [ "whatevervalue" ])

: \ 0.ToString();

Use:

+4

" " " ". , , , /:

:

HttpContext\.Current\.Session\[{("([^"]|\")*")}\]

:

HttpContext.Current.Session[\1].ToString()

:

, , Visual Studio Regex.

, Visual Studio Regex , Visual Studio 6 ( ?) - .

, , regex , , , , , .

+4

, , Visual Studio 2013, , , RegEx. , , RegEx , VS Find/Replace RegEx, RegEx Shortcut .

, , Find/Replace/Surround :

Visual Studio " " " "

+2
0

You can also consider using the Refactor free download tool, available at http://www.devexpress.com/Products/NET/IDETools/RefactorASP/

This is much more than just finding and replacing what they call renaming members with more understandable names. Its various functions will help you improve the code.

0
source

All Articles