String # 1:
/string/morestring/thename
String # 2:
/string/morestring/thename/
Regex:
[^\
Another option:
$last = array_pop(preg_split('#/+#', rtrim($s, '/')));
jeroen's basename solution is very good but might not work on windows, it would also cut out the extension if the URI ends with .something too.
I'd do this:
$last = array_pop(explode('/',rtrim($s,'/')));
I would just use basename().
[^\/]+\/?$
http://rubular.com/r/TeAEWM0jsd