Find and replace a string at a specific string using regex in visual studio

I would like to automatically replace all lines in my solution that are similar to this



with this

NotifyPropertyChanged(Function() VariableParameter)


For more information, see Quick Replace in Find and Replace Using Regular Expression in Visual Studio 2010.

I have no idea how to do this when I have to maintain every parameter of a variable.


source to share

1 answer

Try the following pattern and replacement.

Template: NotifyPropertyChanged\("{[^"]+}"\)

This matches your text while avoiding parentheses. The part {[^"]+}

passes the content ( [^"]+

separated by curly braces) and the bit matches any character that is not a double quote one or more times.

Replacement: NotifyPropertyChanged(Function() \1)

This replaces the agreed text and is fairly easy to understand. The part \1

refers to the first (and only in this example) tagged tag from the template, which is the content between the double quotes.



All Articles