> -----Original Message-----
> From: Teresa Raymond [mailto:[EMAIL PROTECTED]]
> Subject: regex excluding \w.\w\w\w.\w
> 
> I'm trying to figure out how to exclude upload files with 2 periods 
> at the end (b/c of that virus which I forgot the name of, maybe 
> nimba?)  Anyhow, this is what I have but it doesn't work.  When I try 
> to submit with the double periods the test always results in false 
> and never gives the error msg.
> 
> if ($filename=~/(\w.\w\w\w.\w)$/)
> {error($q, "Invalid file name; files must only contain one period.
> Please push the back button on your browser and try again.");
> }

What are you using for $filename?  With that regex, you will get an error
for almost any filename that is at least 7 characters.  In addition, you
will not get a match if your filename has more than one character after the
second '.' The '.' is only working for you by accident because it is really
matching any character (except \n).  It needs to be escaped.
Try something like this:
  if ($filename =~ /\.\w+\.\w+$/){error...}

What this regex says is:
  Match a period followed by one or more word characters [a-zA-Z0-9_],
followed by a period, followed by one or more word characters at the end of
the string.  This will produce the error for the following values of
$filename, to give just a few examples:
  $filename = 'test.com.exe';
  $filename = 'test.c.com';
  $filename = 'test.exe.c';
  $filename = 'test.exe.co';

Hope this helps...
Jason


CONFIDENTIALITY NOTICE:

************************************************************************

The information contained in this ELECTRONIC MAIL transmission
is confidential.  It may also be privileged work product or proprietary
information. This information is intended for the exclusive use of the
addressee(s).  If you are not the intended recipient, you are hereby
notified that any use, disclosure, dissemination, distribution [other
than to the addressee(s)], copying or taking of any action because
of this information is strictly prohibited.

************************************************************************

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to