0

I'm facing a problem where a static class, filled with constant strings, was used across an entire project, and it's been changed for a resource file instead. In that change, the way to access said strings has changed, and the reference to them has to change accordingly.

The reference looked like this at first:

Externalization.Properties.strings.Class1.FIRST_FOO_VALUE
Externalization.Properties.strings.Class1.Subclass1.SECOND_FOO_VALUE

and now looks like this:

Externalization.Properties.strings.Class1_FirstFooValue
Externalization.Properties.strings.Class1_Subclass1_SecondFooValue

Using https://www.regexr.com/ , we've already found that a regex to find all occurences of our first group would look something like this:

"Externalization.Properties.strings.([A-Za-z]+).([A-Za-z]+).([A-Z_]+)"

and we've also found that a possible regex to replace everything would look a bit like this:

"<< Externalization.Properties.strings.$1_$2_$3 >>"

We're almost there. We're trying to figure out how to replace the all caps, underscore structure of the previous references to an upper camel case structure, only using underscores where there used to be dots. How is that possible using regular expressions?

Important note: The find-and-replace operation is taking place in VS2017, and we're using their tool for it. Are such regexes going to behave well in that environment?

Emma
  • 27,428
  • 11
  • 44
  • 69
mgrandmont
  • 35
  • 6

0 Answers0