You know what your delimiters look like, so you don't need a regex. Just a split line. Since you did not specify a language, the implementation in Perl is implemented here:
use strict; use warnings; my $url = "http://www.foo.com/bar/baz/filename.jpg"; my @url_parts = split/\//,$url; my $filename = $url_parts[-1]; if(index($filename,".") > 0 ) { print "It appears as though we have a filename of $filename.\n"; } else { print "It seems as though the end of the URL ($filename) is not a filename.\n"; }
Of course, if you need to worry about certain file name extensions (png, jpg, html, etc.), then adjust them accordingly.
user554546
source share