in reply to most efficient regex to delete duplicate words
# Assuming space delimited words and removing duplicates # not necessarily next to each other my $str = "abc def abc hello def 123 abc"; my %count; $str =~ s/((\w+)\s?)/$count{$2}++ ? '' : $1/eg; print $str,"\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: most efficient regex to delete duplicate words
by coolmichael (Deacon) on Aug 14, 2001 at 06:44 UTC |