SPUG: minimal unmatching regex
Caine, Todd
tcaine at amazon.com
Tue Aug 18 22:47:23 PDT 2009
/^\b$/
> -----Original Message-----
> From: spug-list-bounces+tcaine=amazon.com at pm.org [mailto:spug-list-
> bounces+tcaine=amazon.com at pm.org] On Behalf Of Michael R. Wolf
> Sent: Tuesday, August 18, 2009 12:04 PM
> To: spug-list at pm.org
> Subject: SPUG: minimal unmatching regex
>
> 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