用正则表达式:
var url = 'http://www.baidu.com/path/a/b/c.png';
var data = url.match(/[^/]+(?!.*\/)/g);
console.log(data); // ["c.png"]
lastIndexOf:
var url = 'http://www.baidu.com/path/a/b/c.png';
var format = url .substr(url .lastIndexOf("/") + 1);
return format;