View Single Post
Old Aug 5th, 2007, 6:04 PM   #4
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 843
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
I believe this is what you are looking for:

ereg('^([[:alnum:]_/\-])*/?([[:alnum:]_\-]+\.php)?$', $str);
Both this regular expression and the one you provided will only allow a period before the filename. Your regular expression will match a path with a filename but no extension, such as "whatever/whatever". It will also reject paths that begin with a /. Other than that, it appears okay, although verbose. Also, why not allow file/directory names to begin with a -, as this can occur in URIs?

Last edited by titaniumdecoy; Aug 5th, 2007 at 6:23 PM.
titaniumdecoy is offline   Reply With Quote