Wildcards to regex in VS find & replace

regex, replace, visual-studio

Solution

A capture group when searching/replacing with regex in VS can be given by enclosing something with curly braces.

A backreference can be given simply by using `\1`. There is also a menu to the right of the input fields, containing building blocks.

So you would be simply replacing

return {[^;]+};

by

return filter(\1);

The `[^;]+` specifies that you want at least one character that is not a semicolon, so unless you return delegates or anonymous methods this should work fine.

Problem

I need to convert expressions of the form: ``` return *; ``` into: ``` return filter(*); ``` It seems simple enough to express it with wildcards, however, in visual studio's search & replace dailog, there's no way to associate the first asterisk with the second one. I suppose a regex can do this quite easily, however I know very little about regexes. How do I express this criteria in regex?

Original source