Visual Studio Find and Replace with Regular Expression

I want to replace C # attributes with VB.NET, which means [Serializable] should become <Serializable> .

The pattern (\[)(.+)(\]) Finds the results, but I don’t know how to replace the first and last groups with the corresponding brackets.

I read this page , but I did not understand how to use curly braces for F & R, I tried to wrap groups with it, but that did not work.

+4
source share
2 answers

If you use the Microsoft Power Tools extension that supports regular .NET regular regular expressions, then what would you put in the replacement text box, given your regular expression above:

 <$2> 

where $2 refers to the second capture group in your regular expression, i.e. the text between the brackets.

Please note that this only works with Quick Find from Productivity Power Tools. The usual find / replace in Visual Studio generally uses a different syntax.

+8
source

Find what: \ [{Serializable} \]

Replace with: <\ 1>

0
source

All Articles