Regex to change to sentence case

jkramp picture jkramp · Jun 24, 2009 · Viewed 40.6k times · Source

I'm using Notepad++ to do some text replacement in a 5453-row language file. The format of the file's rows is:

variable.name = Variable Value Over Here, that''s for sure, Really

Double apostrophe is intentional.

I need to convert the value to sentence case, except for the words "Here" and "Really" which are proper and should remain capitalized. As you can see, the case within the value is typically mixed to begin with.

I've worked on this for a little while. All I've got so far is:

 (. )([A-Z])(.+)

which seems to at least select the proper strings. The replacement piece is where I'm struggling.

Answer

Jonas Byström picture Jonas Byström · May 30, 2013
Find:    (. )([A-Z])(.+)
Replace: \1\U\2\L\3

In Notepad++ 6.0 or better (which comes with built-in PCRE support).