Re: Self-recognizing programs and regular expressions
Stefan `Sec` Zehl <[email protected]>
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Message-ID | <[email protected]> |
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.
signature.asc
(application/pgp-signature, 155 B)
-----BEGIN PGP SIGNATURE----- iD8DBQFCLZY7uG8KNKueMhMRAoW3AJ9AqOr0s9HCidH6Uq6Vl3CM2Uyl8ACfeyVC bS106+MqcjSezgt8iKY0WOk= =p97K -----END PGP SIGNATURE-----