Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and Replace All But Text Between Double Quotes in VS2010

Using Quick Replace in Visual Studio 2010, how can I replace all but text surrounded by double quotes. I am not sure if I could use WildCards or Regex to do this. An example is below.

Here is the original code:

TypeByName("bPhone3", "9999");
TypeById("bFirstName", "Don");

and I am wanting to replace the text with something like this:

Type("bPhone3", "9999", Selector.Name);
Type("bFirstName", "Don", Selector.Id);

I am doing this for several hundred changes, so Quick Replace is my only real choice right now. I need to find a way to keep anything in quotes and change the text around it.

like image 933
Andrew Avatar asked Nov 26 '12 20:11

Andrew


1 Answers

So I was tinkering with Visual Studio's find and replace options and this is actually possible using RegEx and tagged expressions. I used this and it works for the strings you listed.

Find What: TypeBy{(.*)}\({"[^"]*"}, {"[^"]*"}\);

Replace with: Type(\2, \3, Selector.\1);

Remember to tag 'use regular expressions' and you should be golden

More information on tagged expressions can be found here

Edit: updated a bit as I noticed you have both name and ID, may need to make a few other changes depending on other small quirks in what you want to change.

like image 156
Kevin DiTraglia Avatar answered Oct 01 '22 18:10

Kevin DiTraglia