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

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



On Fri, May 25, 2001 at 01:31:08PM -0400, Jeff Pinyan wrote:
> On May 25, Randal L. Schwartz said:
> 
> >>>>>> "Jeff" == Jeff Pinyan <jeffp@crusoe.net> writes:
> >
> >>> Or even simpler:
> >>> 
> >>> $b = '\A$b\z';
> >>> 
> >>> The regex is /$b/.  It matches only '$b'. :)
> >
> >Jeff> That fails.  It has to match '\A$b\z'.
> >
> >No, the regex is "dollar b".  it matches "dollar b" and only "dollar
> >b".  It just happens to need a Perl variable called "$b" set to a
> >particular value. :)
> 
> Perhaps I wasn't clear enough...
> 
>   $re = q{^.*(??{$&eq'^.*(??{'.substr($&,7,46).'})\z'?'':'(?!)'})\z};
>   $re =~ $re;
> 
> See that?  That is what must be done.  The regex must match the text of
> the regex itself, and no other text.


Using (??{ }) smells badly like cheating.

Like the "RSA in 4 lines of Perl" program from a few years ago that
just called dc.


BTW, an interesting exercise would be to prove that a certain regex
only matches a certain set of strings, and no other strings.


Abigail

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