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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With