Reputation: 3713
I'm trying to insert a colon everywhere a lowercase letter is followed by an uppercase letter, and add characters around the first word: (from CamelCase
to <Camel>:Case
)
This is my best shot, based on: How to transfer characters between uppercase and lowercase with sed
echo CamelCase | sed -e 's/\([a-z][A-Z]\)/\1:/g'
CamelC:ase
What am I missing?
Upvotes: 2
Views: 1031
Reputation: 784878
Try this sed
:
echo 'CamelCase' | sed -e 's/\([a-z]\)\([A-Z]\)/\1:\2/g'
Camel:Case
echo 'CamelCase' | sed -e 's/\([A-Z][a-z]*\)\([A-Z]\)/<\1>:\2/g'
<Camel>:Case
Upvotes: 6