We have a large solution with many projects in it, and throughout the project in forms, messages, etc we have a reference to a company name. For years this company name has been the same, so it wasn’t planned for it to change, but now it has.
The application is specific to one state in the US, so localizations/string resource files were never considered or used.
A quick Find All instances of the word pulled up 1309 lines, but we only need to change lines that actually end up being displayed to the user (button text, message text, etc).
Code can be refactored later to make it more readable when we have time to ensure nothing breaks, but for time being we’re attempting to find all visible instances and replace them.
Is there any way to easily find these “instances”? Perhaps a type of Regex that can be used in the Find All functionality in Visual Studio to only pull out the word when it’s wrapped inside quotes?
Before I go down the rabbit hole of trying to make my job easier and spending far more time than it would have taken to just go line by line, figured I would see if anyone has done something like this before and has a solution.
You can give this a try. (I hope your code is under source control!)
And replace with
Explanation
Foobarthe name you are searching for[^"]*"a workaround for the missing non greedy modifier.[^"]means match anything but"that means this matches anything till the first".([^"]*"[^"]*")*To ensure that you are matching only inside quotes. This ensures that there are only complete sets of quotes following.[^"]*ensures that there is no quote anymore till the end of the line${}the curly braces buts all this stuff following your companies name into a capturing group, you can refer to it using\1