Ah, that is a little less verbose. 
The limit to the size of the prefix is also a good point.  I will take 
that under consideration.
Brian May
Project Lead
Management Information Systems
Garan, Incorporated
Starkville, Mississippi
Young i Professionals
http://www.youngiprofessionals.com
"Neill Harper" <neill.harper@xxxxxxxx> 
Sent by: midrange-l-bounces@xxxxxxxxxxxx
07/16/2009 12:46 PM
Please respond to
Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
To
"'Midrange Systems Technical Discussion'" <midrange-l@xxxxxxxxxxxx>
cc
Subject
RE: Using a regular expression to validate a file name
Looks ok to me you could also have gone for
"/^[\w | -]+\.\w+$/"
The only comment i have is that your only validation on the extension is
that it is at least 1 char. Depending on your needs you might want to set 
a
max for the extension. 
"/^[[\w | -]+\.\w{1,4}$/" forces the extension to be at least 1 char and 
at
most 4 chars.
Neill
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of BMay@xxxxxxxxx
Sent: 16 July 2009 16:19
To: midrange-l@xxxxxxxxxxxx
Subject: Using a regular expression to validate a file name
I just need a quick sanity check.  I am not as proficient with regular 
expressions as I would like.
I have been using the following expression to validate file names uploaded 
and retrieved from our root IFS file system
"/^\w+\.\w+$/"
This ensures that the file name and suffix contain only letters, numbers, 
and underscores.
I had a new requirement to allow dashes in the file name.  So I changed 
the expression to this.
"/^[A-Za-z0-9_-]+\.\w+$/"
Any gotchas that I might be missing in this change?
Thanks,
Brian May
Project Lead
Management Information Systems
Garan, Incorporated
Starkville, Mississippi
Young i Professionals
http://www.youngiprofessionals.com
As an Amazon Associate we earn from qualifying purchases.