Just for fun, I'll assume that I got the output from "man" and someone else has removed the backspaces for me so I want to remove the duplicates... And based on my experience, I may end up with tripled or quadrupled letters as well.
You could do pretty well by finding "words" that contain only doubled letters and modifying those. But a "good" way to do this hasn't popped into my brain yet...
Like I said, that doesn't seem like a great way to do it (untested as well). :-} - tye (but my friends call me "Tye")my $inWord= "[-\\w'(),]"; my $notWord= "[^-\\w'(),]"; s#($notWord)(($inWord)\3(?:$inWord)*($inWord)\4)($notWord)# my( $pre, $word, $post )= ( $1, $2, $5 ); my $len= length($word); for( $word =~ /(.)(\1*)/g ) { $len= length($2) if length($2) < $len; } $word =~ s/(.)\1{$len}/$1/g if 0 < $len; $pre . $word . $post; #ge
In reply to (tye)Re: Removing characters
by tye
in thread Removing characters
by TStanley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |