[Javascript] RegEx for validating a file name

Rod Coate rod.coate at falkirkcollege.ac.uk
Fri May 20 03:48:24 CDT 2005


I am using the filename validation for a html/php contentmanagement system I am creating. (I know that there are plenty of these out there, but I am using this as a project to teach myself php and stretch my javascript knowledge).
The idea is that users can create htm files and css files via a web interface. These will then be stored as templates on a mysql database and also as files on the web server. At some point I will probably restrict the file types even more, but I am happy at the moment to just validate the names down to valid file names.

I appreaciate all of the comments so far, but as shawn said - the best reply is a relevant answer to the question. 

Cheers,
Rod



-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of Shawn Milo
Sent: 19 May 2005 19:05
To: [JavaScript List]
Subject: Re: [Javascript] RegEx for validating a file name


Well, I'm assuming that the OP knew why he wanted it that way. He
specified alphanumeric and a three-digit extension, so that's what I
matched. I tend to be extremely annoyed when I ask a question on a
mailing list and the replies explain why it's a bad idea, rather than
how to do it.

For example, I found a post yesterday where someone had asked how to
mount a Samba share over the internet from their home machine. The
only reply was one saying that this was very unsecure and should never
be done. I think that this information is useful to the OP, but should
only be provided if the reply also contains some kind of answer to the
question. I think that people who leave those kind of replies are more
interested in appearing smarter than someone else than helping someone
else.

No offense to Paul and Hassan -- your comments were constructive to
the situation in this case. I guess I just felt like bitching about
the topic, and the opportunity arose in my 'home' mailing list.  Also,
I probably felt the need to explain why I provided a solution for what
might have been the wrong question -- to be helpful.

Shawn

On 5/19/05, Paul Novitski <paul at novitskisoftware.com> wrote:
> At 09:49 AM 5/19/2005, Hassan Schroeder wrote:
> >..just want to forget it altogether? :-)
> >
> >Using Linux/MacOS/Windows,
> >
> >  "log4j.properties" is a valid filename
> >  "Hassan_Schroeder.resume.pdf" is a valid filename
> >  "Picture of the Dogs.jpeg" is a valid filename
> >
> >..none of which would pass the proposed regex.
> 
> Quite right -- one of my brain's feet must have been standing momentarily
> in MS-DOSville.
> 
> P.
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 


-- 
Voicemail any time at:
206-666-MILO
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list