Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 6th, 2007, 2:01 AM   #11
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 836
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
I believe you just need to escape the / to get it to work with preg_match...

$regExp = '/^([[:alnum:]_][[:alnum:]_\-]*\/?)*?([[:alnum:]_]+[[:alnum:]_\-]*\.php)?$/i';
echo preg_match($regExp, $fileName);
Also, you will see that I edited my previous post; I believe you are using the regular expression I posted originally, which will match dir/.php; the updated version will not.

Quote:
Originally Posted by grimpirate View Post
What exactly is it the '?' character does? The PHP documentation's description of it doesn't make sense to me.
The ? makes the preceding token optional; when it follows a *, it makes the matching engine lazy (as opposed to greedy) with regard to the preceding token. See here.

Last edited by titaniumdecoy; Aug 6th, 2007 at 2:20 AM.
titaniumdecoy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:19 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC