Path: utzoo!utgpu!news-server.csri.toronto.edu!turing.toronto.edu!ruhtra Newsgroups: comp.editors From: ruhtra@turing.toronto.edu (Arthur Tateishi) Subject: Re: repeated character editing Message-ID: <1991Mar30.024851.24414@jarvis.csri.toronto.edu> Keywords: vi sed Organization: CSRI, University of Toronto References: <1991Mar28.181335.7813@cbnewsm.att.com> Distribution: usa Date: 30 Mar 91 07:48:51 GMT Lines: 17 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 If your example was a typo and should have been: APLE pie then the following reg-exp will work. :s/\(.\)\1*/\1/g -- Red Alert. -- Q, "Deja Q", stardate 43539.1 Arthur Tateishi g9ruhtra@zero.cdf.utoronto.edu