Visual Studio: find and replace ALL CAPS with Title Case
Consider the need to replace window titles that are currently in all caps i.e. "ADD PRESCRIPTION", "ADD PATIENT", to the form "Add Prescription" and "Add Patient".
I am using the Visual Studio search dialog to find all of the strings that are all caps using the regex "([A-Z]|[ ])*". That works great.
Is it possible to find and replace in Visual Studio with a regex on both the find and replace?
I can't seem to find anything that says that it is, so if it's not are there any tools that would let me replace it.
Answers
Don't know a Visual Studio way but to roll out your own C# program which handles the replace part explicitly.
But in Vim, you can use :%s/\([A-Z]\)\([A-Z][A-Z]*\)/\1\L\2/g command. The \L is used to change the matching group \2 (a.k.a back reference) to lower case.
Before:
"HELLO WORLD" This is just a test. SO stands for StackOverflow.
After:
"Hello World" This is just a test. So stands for StackOverflow.