perl -p -i.1 -e 's/(?<=[A-Z])[a-z]*(?=[A-Z])//g' example.txtwill transform string
or
perl -p -i.1 -e 's/(?<=[A-Z])[a-z]*(?=[A-Z])//g unless /^>/' example.txt
(in the case of file with FASTA header)
atgcATGCcgtaACGTtgcaCGTAcgta
to
atgcATGCACGTCGTAcgta
(solution suggested by Leah McHale https://pro.osu.edu/profiles/mchale.21/)