[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] 4 Consecutive Letters




Peter Scott wrote:
> 
> At 07:58 PM 8/14/00 -0400, Rick Delaney wrote:
> > > >      perl -ne'@a=a..z;for$i(0..22){print,last if/@a[$i..$i+3]/x}'
[...]
> >     perl -ne'print,last if join("",a..z)=~join"|",/(?=(....))/g,_'
> 
> Well you can make it three characters shorter instead of two longer and see
> more than one result by removing the ',last' :-)

Hah!  I didn't look closely enough at what the C<last> was doing in the
other solution.  I thought somewhere along the line we were *supposed*
to print only the first occurrence.  But it runs faster this way.  :-)

Ah well, here then:

    perl -ne'print if join("",a..z)=~join"|",/(?=(....))/g,_'

or for the backwards among us:

    perl -ne'join("",a..z)=~join("|",/(?=(....))/g,_)&&print'

-- 
Rick Delaney
rick.delaney@home.com

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe