I have an enormous list of the following items:
_tags.Add(Foo.Bar,
new Baz(
...
));
_tagNames.Add("Bar",
_tags[Foo.Bar]);
wh开发者_如何转开发ere Bar and Baz(...) vary, and _tags, _tagNames and Foo stay the same.
I want to transform to
case "Bar":
_tags.Add(Foo.Bar,
new Baz(
...
));
_tagNames.Add("Bar",
_tags[Foo.Bar]);
break;
I am using Visual Studio, which supports regex.
Any ideas?
Thanks!
Update: VS couldn't handle 2300 instances of this regex. I got this working in Eclipse:
Search Pattern: _tags.Add((?:.|\R)*?_tags[Foo.(.*?)]);
Replace: case "\1":\n\0\n break;
Tested on VS 2008:
_tags\.Add\((.|\n)@_tags\[Foo\.{(.@)}\]\);
Whith this as replacement string:
case "\1":\n\0\nbreak;
You might have to insert some tab-characters to keep your indention (or use auto-format).
UPDATE:
Tested and fixed regex for usage in vs
精彩评论