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

Re: [FWP] japhy had a silly idea...



On May 25, Randal L. Schwartz said:

>>>>>> "Ilmari" == Ilmari Karonen <iltzu@sci.fi> writes:
>
>Ilmari> On Fri, 25 May 2001, Jeff Pinyan wrote:
>>> I tried for an hour and a half or so to craft a regex that matches itself,
>>> and ONLY itself.
>>> 
>>> I came up with nothing -- well, several dead ends at least.
>
>Ilmari> What are the constraints?  If embedding Perl code is allowed, I'd say
>Ilmari> the problem essentially reduces to constructing a quine.
>
>Ilmari> (No, I don't have the time to attempt a solution just now..)
>
>Or even simpler:
>
>$b = '\A$b\z';
>
>The regex is /$b/.  It matches only '$b'. :)

That fails.  It has to match '\A$b\z'.

I've fixed my last attempt as well:

  123456789_123456789_123456789_123456789_123456789_12
  ^.*(??{$&eq'^.*(??{'.substr($&,7,41).'})\z'?'':1})\z

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
** I need a publisher for my book "Learning Perl's Regular Expressions" **


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