Reputation: 8335
I have a bunch of object variables which are all initialised in their declarations such that:
Private _myObject As New ThisObject("SomeString")
where ThisObject
is one of a number of object types, but all are initialised using a string.
I would like to use the Visual Studio Find/Replace dialog box to search for "As New
" then replace everything from "As New
" to the first set of speech marks with some text such that:
EDIT
My original example could be solved using other methods. This example is more representative of the actual problem:
Private _myObjectA As New ThisObjectA("SomeString")
Private _myObjectLongName As New ThisObjectLongName("SomeString")
changes to:
Private _myObjectA = [someCode]"SomeString")
Private _myObjectLongName = [someCode]"SomeString")
Obviously this would be doable in code, reading a text file, but I'm specifically asking about the capabilities of the Visual Studio Find/Replace dialog.
OLD EXAMPLE:
Private _myObjectA As New ThisObjectA("SomeString")
Private _myObjectB As New ThisObjectB("SomeString")
changes to:
Private _myObjectA = [someCode]"SomeString")
Private _myObjectB = [someCode]"SomeString")
Upvotes: 1
Views: 176
Reputation: 3318
You can do this sort of things easily using Shift + Alt + Arrow keys
and Ctl + K + \
with Find/Replace
dialog box. Refer my blog for more information.
Update: Follow the steps, as shown in the screen shot.
Upvotes: 2
Reputation: 112259
You can use regular expressions in Visual Studio. However oddly enough, VS does not use the usual .NET Regex-syntax:
In VB you would write:
s = Regex.Replace(s, "New ThisObject\w*","[somecode]")
Upvotes: 2