in reply to Removing characters
First, the regex is very displeasing. A good way to remove duplicate letters would be: s/([a-z])\1/$1/ig) { Take advantage of capturing parens and back-references!
More seriously, however, is that your code will match on such text as "this too shall pass". How do you determine which duplicates you want to remove and which you don't? Any solution which removes the backspaces in one step and the duplicates in the second step is doomed to failure.
Here's a better approach:
However, that won't work properly if there are multiple backspaces in a row.#!perl -p s/.\cH//g;
A more generic and robust solution would be to use col. (Shameless plug. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re2: Removing characters
by tye (Sage) on Jan 09, 2001 at 04:31 UTC |