[英]Slice, trim the string from a specific character
var text = ~/Desktop/Bon/ai2html-output/home-pro-Artboard_1.jpg
In js how would I get the final file name.在 js 中,我将如何获得最终文件名。 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 /^.*\//
:贪婪地删除所有前导文本,包括最后一个斜杠
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.