Removing unique elements from string
(GolfScript, 15 13 characters)
:;{.;?);>?)},
GolfScript is not one of the top 20, but a codegolf without GolfScript... (run it yourself)
Previous Version: (run script)
1/:;{;\-,;,(<},
Perl, 28 24 characters (includes 1 for 'p' option)
s/./$&x(s!$&!$&!g>1)/eg
Usage:
> perl -pe 's/./$&x(s!$&!$&!g>1)/eg'
helloworld
llool
At first I thought I could do this with negative look-ahead and negative look-behind, but it turns out that negative look-behinds must have a fixed length. So I went for nested regexes instead. With thanks to mob for the $&
tip.
J, 12 characters
Having entered a valid Perl answer, here's an invalid (language not in the TIOBE top 20) answer.
a=:#~1<+/@e.
Usage:
a 'helloworld'
llool
Declares a verb a
which outputs only non unique items.