Re: Self-recognizing programs and regular expressions

Abigail <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
On Mon, Mar 07, 2005 at 11:05:15PM +0000, Ton Hospel wrote:
> Ah, the idea seems salvagable, but less elegant:
> 
> this sequence is self matching:
> ^
> ^\^
> ^\^\\\^
> ^\^\\\^\\\\\\\^
> ....
> 
> so an infinite sequence of ^ with 2**n-1 \ after the n-th ^


This is also self matching:

  \A\\A\\\\A\\\\\\\\A....

with 2**(n-1) \s before the n-th A.



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.



Abigail
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCLOpCBOh7Ggo6rasRAiXrAJwLB5RV9bgm0wQ5vC3gdcWBbB6FfwCfVuaX
y3V8Sm0tfUBNUgAwGJg1wd4=
=nluJ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.