SPUG: minimal unmatching regex
Ingy dot Net
ingy at ingy.net
Wed Aug 19 00:38:32 PDT 2009
On Tue, Aug 18, 2009 at 10:33 PM, Steve Sandvik <ssandv at gmail.com> wrote:
> well, /$^/ seems like a plausible starting point. Or ending point.
> Or something. :-)
$^ = "";
$anything =~ /$^/;
> Steve Sandvik
> On Tue, Aug 18, 2009 at 12:04 PM, Michael R. Wolf<MichaelRWolf at att.net>
> > Question:
> > What's the smallest (comprehensible) regex that's guaranteed to fail
> > all input?
> > Motivation:
> > I'm creating a lab for perl classes. I want to provide the stub of a
> > 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
> > 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/
> 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/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the spug-list