Reputation: 3320
var text = ~/Desktop/Bon/ai2html-output/home-pro-Artboard_1.jpg
In js how would I get the final file name. Basically getting any string after the last '/'. It will always change.
Upvotes: 0
Views: 123
Reputation: 7616
You can use this:
var text = '~/Desktop/Bon/ai2html-output/home-pro-Artboard_1.jpg';
var filename = text.replace(/^.*\//, ''); // 'home-pro-Artboard_1.jpg'
Explanation of regex:
/^.*\//
: greedily remove all leading text up to and including the last slashUpvotes: 2