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.
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 slash
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.