Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!psuvm!blekul11!ffaac09 From: FFAAC09@cc1.kuleuven.ac.be (Nicole Delbecque & Paul Bijnens) Newsgroups: comp.editors Subject: Re: repeated character editing Message-ID: <91089.144544FFAAC09@cc1.kuleuven.ac.be> Date: 30 Mar 91 14:44:43 GMT References: <1991Mar28.181335.7813@cbnewsm.att.com> <1991Mar29.145724.5569@cbnewsm.att.com> Distribution: usa Organization: K.U.Leuven - Academic Computing Center Lines: 34 In article <1991Mar29.145724.5569@cbnewsm.att.com>, cadman@cbnewsm.att.com (jerome.schwartz) says: > >In article <1991Mar28.181335.7813@cbnewsm.att.com>, cadman@cbnewsm.att.com >(jerome.schwartz) writes: >> >> How would I do a simple edit command, vi map or sed script, to >> replace all occurrences of repeated characters in a file with one >> of each of the characters. >> >> ie: This: AAAAPPPPLLLLEEEE ppppiiiieeee >> to this: APPLE pie >> >> Thanks in advance, >> Jerry > >The example should have been: > >AAAAPPPPPPPPLLLLEEEE ppppiiiieeee > >With 2 sets of 4 P's. > >Still with no success, The slighty changed problem has the next solution: sed -e 's/\(.\)\1\1\1/\1/g' inputfile > outfile This changes 4 repeates of the same letter to 1 letter. It leaves all the other letters (the space in your example) as is. -- Polleke (Paul Bijnens) Linguistics dept., K. University Leuven, Belgium FFAAC09@cc1.kuleuven.ac.be