R, 6060 55 bytes
\(s)gsub("([a-z])([^az][^a-z]*)([a-z]?)","\\U\\1\\2\\L\\3""\\U\\1\\L\\2",s,T,T)
Attempt This Online!Attempt This Online!
Some explanation: This solution uses one single gsub
and a regex which matches the pairs of letters: (1) the first letter, (2) followed by zero or more non-letter characters in-between and (32) an optional second letter. Accordingly, the 1st matchcatching group is capitalized and the 3rd2nd one is converted to the lowercase. Two positional arguments stand for ignore.case = TRUE
and perl = TRUE
.