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

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



>From fwp-l Fri May 25 11:23:25 2001

On Fri, 25 May 2001, Jeff Pinyan wrote:

> The regex must ONLY MATCH ITSELF.  No other text
> should match it.
>
>   ^.*(??{$&eq'^.*(??{'.substr($&,7,46).'})\z'?'':'(?!)'})\z

Not being a wizard of ??, I clearly see how this regex matches itself
nicely ... but I don't understand why any old string with 46 characters
between the beginning and end stuff shouldn't work:

#!/usr/bin/perl -w

use re 'eval';

$re = q#^.*(??{$&eq'^.*(??{'.substr($&,7,46).'})\z'?'':'(?!)'})\z/#;
$test =            '^.*(??{'.    'X' x 46   .'})\z';

if($test =~ /$re/) {
    print "Japhy has more work to do.\n";
} else {
    print "Japhy was right after all.\n";
}

__END__
Japhy was right after all.


The first .* should greedily capture to the end of the string, at
which point, shouldn't the substr($&, 7, 46) eq ('X' x 46), and therefore
the regex be true?

-Aaron

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