views:

270

answers:

1

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.

+2  A: 

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.
m3rLinEz
I know how to write the regex to do it in on input text also I'm also curious if there is a way to do it in VS.
msarchet
Totally forgot to upvote you because this is a good answer, but not The Answer
msarchet