Reputation: 529
How can I select all property names that starts with an underscore and replace it with the same property name but without the underscore? It's a very tedious task and I want to use the VS2012 find and replace function to make it easy.
Edit:
I managed to select all property names with underscores with this regex
(?<!\w)_\w+
But how to replace it with the same class name excluding the underscore?
Upvotes: 3
Views: 758
Reputation: 3950
Put the below regex in the appropriate field inside Find and Replace
window:
Find what: <_{[A-Za-z0-9]+}
Replace with: \1
Upvotes: 0
Reputation: 48751
In programming C#:
withoutUnderscore = Regex.Replace("_test", @"(?<!\w)_(\w+)", "\1");
Edit #1
In Visual Studio Find and Replace dialog:
1-Type (?<!\w)_{\w+}
in Find What field
2-Type \1
in Replace with field
Upvotes: 1
Reputation: 529
Find (?<!\w)_
and replace it with nothing.
Noticed that the replace field treats regex only as a string.
Upvotes: 4