RegEx / Regular Expression for filename and file extension

This is a helpful snippet that I have found myself searching for in the google machine. Hopefully this helps you out!

$filename = "thisismyfilename.ext";

preg_match("/(.*)\.([^\.]+)$/", $filename,  $matches);



Wednesday, April 7th, 2010 PHP

Leave a Reply

You must be logged in to post a comment.

[ad code=1 align=center]