0

I'm working in a group that's converting an old WinForms app to a WPF app, using the MVVM pattern. Thus, we're having to write a lot of large models. I thought I'd write a find-and-replace regex so we can write our private variables:

private string myString;

and do a find-and-replace across the large file and get:

 private string myString;
 public string MyString
 {
     get { return myString; }
     set { SetProperty("MyString", ref myString, value); }
 }

this isn't too bad, the only issue I have is converting myString to MyString.

Is there a way, using straight regex capture groups, to replace a character with it's uppercase version, within Visual Studio's find-and-replace? All my searches just turn up using C# code to do the conversion, which obviously isn't possible in this context.

Jonesopolis
  • 25,034
  • 12
  • 68
  • 112
  • I don't think regexes *within VS find&replace* can change case, but you could write a quick console app to do it. – Rawling May 01 '15 at 14:07
  • Can you use a regular find and replace without regex? I know that may end up replacing MyString contained in a larger word. – Derek Jul 20 '15 at 12:17

1 Answers1

0

When I come across this issue, the sometimes fastest way is to replace everything with something completely different at first like "MyNOTString", and then back to "MyString" to get the right capital letters. It does not seem that you can get what you are asking for in Visual Studio without using Macros and such.

Another solution would be to open all the project files in a different tool like Notepad++, which supports writing /U to turn something into uppercase. See this answer.

Community
  • 1
  • 1
William S
  • 881
  • 6
  • 17