SPUG: minimal unmatching regex

Steve Sandvik ssandv at gmail.com
Tue Aug 18 22:33:57 PDT 2009


well, /$^/ seems like a plausible starting point.  Or ending point.
Or something. :-)

Steve Sandvik

On Tue, Aug 18, 2009 at 12:04 PM, Michael R. Wolf<MichaelRWolf at att.net> wrote:
> Question:
> What's the smallest (comprehensible) regex that's guaranteed to fail against
> all input?
>
> Motivation:
> I'm creating a lab for perl classes.  I want to provide the stub of a script
> that compiles, but always fails to match.  Unfortunately, the obvious
> minimal RE of // matches *everything*.
>
> Here's a stub of the lab...
>
> # TODO... replace the following line with your regular expression to match
> zip codes.
> my $zip_re = qr//;
>
> like('98107', $zip_re, 'Simple 5-digit zip'),
> like('07748', $zip_re, 'Simple 5-digit zip with leading zero'),
>
> unlike('1234',          $zip_re, 'Four digits');
> unlike('123456',        $zip_re, 'Six digits');
>
> --
> Michael R. Wolf
>    All mammals learn by playing!
>        MichaelRWolf at att.net
>
>
>
>
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
>    POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>   MEETINGS: 3rd Tuesdays
>   WEB PAGE: http://seattleperl.org/
>


More information about the spug-list mailing list