regex - Capitalization and acronyms -


i'm trying come regex capitalize words leave uppercase abbreviations , acronyms are.

for example, i'd 'london' become 'london' 'la' remain is. ideally also, 2 character words uppercased, e.g., 'la' → 'la'.

it's easy enough capitalization bit, abbreviations/acronyms eluding me. tips appreciated.

try gnu sed:

sed 's/\b.\b/\u&/g;s/\b..\b/\u&/g' file 

 $ cat file lorem ipsum dummy text of printing , typesetting industry.  lorem ipsum has been industry's standard dummy text ever since 1500s,  when unknown printer took galley of type , scrambled make type specimen book.  $ sed 's/\b.\b/\u&/g;s/\b..\b/\u&/g' file lorem ipsum dummy text of printing , typesetting industry.  lorem ipsum has been industry's standard dummy text ever since 1500s,  when unknown printer took galley of type , scrambled make type specimen book. 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -