Given a URL path, I am attempting to create a regular expression to match if the path points to a directory, and to not match if it points to file extensions .php, .js, .html, .htm, etc.
Match:
/www/site/path/ny/
Match:
/www/news/state.208/ii
Do not match:
/www/news/index.php
Do not match:
/www/site/fr/post.py
Here is my regex that I've been working with:
^([a-zA-Z0-9/_\-]*[^/])$
This regex does what I want, but it isn't precise enough. It assumes it is a path to a file and stops matching whenever it comes across a ".", but I need to consider the possibility that the directory name contains a ".", like in the example above.
I also tried using negative look behinds with no luck:
^(.(?!\.php)|(?!\.htm?l)|(?!\.js))$
file_exists(),is_dir(),pathinfo(),basename(), and other functions may be more appropriate than complex regex here.