Reputation: 35
I'd like to replace automatically all the strings in my solution which are like this one
NotifyPropertyChanged("VariableParameter")
with this
NotifyPropertyChanged(Function() VariableParameter)
by "Quick Replace" in "Find and Replace" using a regular expression in Visual Studio 2010.
I have not the slightest idea how to do this when I have to keep each different variable parameter.
Upvotes: 3
Views: 1544
Reputation: 96477
Try the following pattern and replacement.
Pattern: NotifyPropertyChanged\("{[^"]+}"\)
This matches your text, while escaping the parentheses. The {[^"]+}
portion tags the contents (via the curly braces) and the [^"]+
bit matches any character that isn't a double-quote, one or more times.
Replacement: NotifyPropertyChanged(Function() \1)
This replaces the matched text and is fairly straightforward to understand. The \1
portion refers to the first (and only, in this example) tagged text from the pattern, which is the content between double-quotes.
Upvotes: 3