in reply to Find duplicate digits

straightforward, accept one repetition but not two.

print grep { /(\d).*\1/ && ! /(\d).*\1.*\1/ } map {sprintf "%04d",$_} +(0..9999)

Tried to do it in one regex but I couldn't find out how to negate the match \1, [^\1] obviously doesnt work and all negative look aheads get confused by the end of string...

Cheers Rolf

UPDATE: sorry nothing new :( ...Re: Find duplicate digits

Replies are listed 'Best First'.
Re^2: Find duplicate digits
by LanX (Saint) on Apr 08, 2010 at 01:00 UTC
    another variation:

    print grep { /(\d).*\1/ and eval "2 == tr/$1//" } map {sprintf "%04d +",$_} (0..9999)

    Cheers Rolf