regular expression that doesn't match any string [repost as thread root]

From: R. Joseph Newton (rjnewton_at_efn.org)
Date: 02/25/04


Date: Wed, 25 Feb 2004 00:25:26 -0800
To: Beginners--Perl <beginners@perl.org>,   "Qznur?= Tastan" 	<oznurtastan@su.sabanciuniv.edu>

Reposted as new thread:

[Note: I am reposting this as a new message, in order to start a new thread.
Please remember to use the new message command, rather than a reply, when
starting a new subject. For many of us with threaded browsers, your message got
lost way out on an unrelated thread.--Joseph]

Hi all
Just for fun (really no context) i was wondering how to create regular
expressions that
will never match any string.

/^[^\w\W]/ is one of them am I right? No string can start with a character
that is neither alphanumeric nor nonalhanumeric.

But why does
/^[^.\n]/ matches .
doesn't that mean the string should begin a character that is not any
character or not a newline(nothing else should be left).

Could someone enligthen me?
Below is to code I use to check.
thanks
oznur

use strict;
use warnings;

my $string="does it match";

if ($string=~/(^[^\w\W])/){
  print "matches $1\n";
}
else {
  print "doesn't match \n";
}

if ($string=~/(^[^.\n])/){
   print "matches $1\n";
}
else {
   print "doesn't match \n";
}



Relevant Pages