develooper Front page | perl.fwp | Postings from March 2005

Re: Self-recognizing programs and regular expressions

Thread Previous | Thread Next
From:
Stefan `Sec` Zehl
Date:
March 8, 2005 04:12
Subject:
Re: Self-recognizing programs and regular expressions
Message ID:
20050308121035.GD45541@ice.42.org
On Tue, Mar 08, 2005 at 00:56 +0100, Abigail wrote:
> Years ago, while I was still writing JAPHs, I was looking for a regex
> matching itself - and nothing but itself (regexes that match themselves,
> and also other strings are easy and IMO, not interesting), but I never
> found one. The search wasn't entirely fruitless, it did lead to:
> 
>        my $qr =  qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
>           $qr =~  s/$qr//g;
>     print $qr, "\n";
> 
> 
> But that's a far cry from what I wanted to find.

What about this one?

^(??{$b=q(^(??{$b=q(%s);quotemeta(sprintf$b,$b)})\z);quotemeta(sprintf$b,$b)})\z

CU,
    Sec
-- 
In 1968 it took the computing-Power of 2 C-64 to fly a rocket to the moon.
Now, 1997 it takes the Power of a Pentium 133 to run Microsoft Windows 95.
                    Something must have gone wrong.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About