Find words starting with underscores.

How can I select all property names starting with an underscore and replace it with the same property name, but without an underscore? This is a very tedious task, and I want to use the VS2012 function for search and replace in order to simplify it.

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, except underscore?

+3
source share
3 answers

Find (?<!\w)_and replace nothing.

It is noted that the replace field processes the regular expression only as a string.

+4
source

When programming C #:

withoutUnderscore = Regex.Replace("_test", @"(?<!\w)_(\w+)", "\1");

Edit # 1

" Visual Studio":

1-Type (?<!\w)_{\w+}

2-Type \1

enter image description here

+1

Place the following regular expression in the appropriate field inside the window Find and Replace:

Find what: <_{[A-Za-z0-9]+}
Replace with: \1
0
source

All Articles