×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Walden you are right [\w | -] is either or. But I followed it with a +,
which means either or, one or more times. This reg ex does allow for
blah-_.txt for example.
The validation of the file extension was just a suggestion and the 1 to 4
limit was just used to show an example, I don't know the exact reason for
the use in this thread but I thought I'd put it out there as an option, no
harm in extra knowledge!!
Finally reading my email back I spotted a mistake in the second regex there
was an extra [ in there it should have read.
"/^[\w | -]+\.\w{1,4}$/"
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Walden H. Leverich
Sent: 16 July 2009 20:26
To: Midrange Systems Technical Discussion
Subject: RE: Using a regular expression to validate a file name
Ah, that is a little less verbose.
Less verbose not always good. :-) And your expression allowed either -
or _, [\w | -] allows only -, which is your intent?
The limit to the size of the prefix [suffix?] is also a good point.
Why? Why limit the length of the extension? Perhaps a minimum length
{3,} to make it a minimum of 3, but why a max of 4? It's been a long
time since we were limited to 8.3 filenames.
-Walden
As an Amazon Associate we earn from qualifying purchases.