tags:

views:

39

answers:

1

Edit: (here is a better live example:

http://vzio.com/upload/reg_pattern.php)

I am very bad at regular expressions, but I have a regular expression that is working okay, except for one issue:

/\/(.*?).php/

I only need this regular expression to find things like:

/this-a-valid-page.php {some words here} /anotherpage.php { some words here} http://www.google.com

but do not find URLs the problem i am having is that it find this parts of full URLS i want it to avoid these all together. http://www.google.com/page.php because i have another function that does something different than the filename reg exp.

+1  A: 

/^\/(.*?)\.php$/

bash:~$ php -a
php > $test = array('pass' => '/test.php', 'fail' => 'http://example.com/test.php');
php > echo preg_match('/^\/(.*?)\.php$/', $test['pass']);
True
php > echo preg_match('/^\/(.*?)\.php$/', $test['fail']);
False
CodeJoust
thanks for the post, but for some reason it works for one but not more than one ie-> /home-splash-add.php this is a test to see if it will do them all /home-splash-add.php it misses both of them
jason
It should work, only thing required is the / needs to be the first character, and the end should be .php, hence the carrot and dollar signs.
CodeJoust
here is a better example http://vzio.com/upload/reg_pattern.php
jason
Then it should work?
CodeJoust